Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6845497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:30:28+00:00 2026-05-27T00:30:28+00:00

I would like to combine to linq queries into the same gridview. Though I

  • 0

I would like to “combine” to linq queries into the same gridview. Though I don’t think I could use innerjoin on this.
The queries get orders from the database, and I have 2 tables with orders from different places.
In the gridview I want to display all orders from first table and second table.
Like this:

OrderID - Item - Amount etc ---From table 1
OrderID - Item - Amount etc ---From table 2
etc..

My current query for getting orders from the first table are:

var query = from o in db.Orders
            join y in db.OrderLines on o.OrderID equals y.OrderID
            join x in db.Products on y.ItemNumber equals x.ItemNumber
            where o.AccountNumber == AppSession.CurrentLoginTicket.AccountNumber
            select new
            {
                o.OrderID,
                o.AxaptaSalesId,
                y.ItemNumber,
                x.Name,
                x.ProductFormatName,
                y.Quantity,
                y.Price,
                Status = dltRep.getOrderStatus(o.OrderID, o.AxaptaSalesId, y.ItemNumber).Substring(0, dltRep.getOrderStatus(o.OrderID, o.AxaptaSalesId, y.ItemNumber).LastIndexOf("|")),
                Levering = dltRep.getOrderStatus(o.OrderID, o.AxaptaSalesId, y.ItemNumber).Substring(dltRep.getOrderStatus(o.OrderID, o.AxaptaSalesId, y.ItemNumber).LastIndexOf("|")).Replace("|", "")
            };

The other table would have the same information. It’s named AxSale.

I hope this is possible and someone could help me out 🙂

EDIT: new “problem”

I wan’t to get the variable createdDate to be the first element x.CreatedDate in either the first linq seq. or the second.
How do I do this?

var created = purchases.OrderByDescending(x => x.CreatedDate).
                Select(x => new { x.CreatedDate, x.LineSupplierAccountNO }).
                GroupBy(x => x.LineSupplierAccountNO);

if (created.Count() > 1)
{
    created = purchases.OrderBy(x => x.CreatedDate).
                Select(x => new { x.CreatedDate, x.LineSupplierAccountNO }).
                GroupBy(x => x.LineSupplierAccountNO);
}

var createdDate = created.FirstOrDefault();

Solution code:

var created = purchases.OrderBy(x => x.CreatedDate).Select(x => x);

if (created.GroupBy(x => x.LineSupplierAccountNO).Count() > 1)
{
    created = purchases.OrderByDescending(x => x.CreatedDate).Select(x => x);
}

var createdDate = created.First().CreatedDate;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:30:28+00:00Added an answer on May 27, 2026 at 12:30 am

    Use UNION operator to join results with same fields. Here is example from http://code.msdn.microsoft.com/windowsdesktop/101-LINQ-Samples-3fb9811b

    public void Linq49() 
    { 
        List<Product> products = GetProductList(); 
        List<Customer> customers = GetCustomerList(); 
    
        var productFirstChars = 
            from p in products 
            select p.ProductName[0]; 
        var customerFirstChars = 
            from c in customers 
            select c.CompanyName[0]; 
    
        var uniqueFirstChars = productFirstChars.Union(customerFirstChars); 
    
        Console.WriteLine("Unique first letters from Product names and Customer names:"); 
        foreach (var ch in uniqueFirstChars) 
        { 
            Console.WriteLine(ch); 
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being new to LINQ, I created a couple queries and would like to combine
I have the following three SQL queries. I would like to combine them into
I have two views that I would like to combine into one. The first
In an asp.net application, I would like to combine the use of the Webclient
This is the sequel to this question . I would like to combine three
I would like to combine arrrays @a , @b , and @c into a
I have two queries which i would like to combine There are 4 tables
I would like to combine several lists or arrays into a single record array.
I would like to combine 2 commands into 1, if its possible. <%= render
I have two regualar rexpressions I would like to combine into the one for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.