views:

463

answers:

1

I am trying to populate a treeview control with some info and for that I am using 2 separate LINQ as follows;

    Dim a = From i In CustomerTable _
            Group By ShipToCustName = i.Item(6), BillToCustName = i.Item(4) Into Details = Group, Count() _
            Order By ShipToCustName



    Dim b = From x In a _
            Group By ShipToName = x.ShipToCustName Into Group, Count() _
            Order By ShipToName



    For Each item In b
        Console.WriteLine("Shitp To Location: " + item.ShipToName)
        For Each x In item.Group
            Console.WriteLine("...BillTo:" + x.BillToCustName)
            For Each ticket In x.Details
                Console.WriteLine("......TicketNum" + ticket.Item(0).ToString)

            Next
        Next
    Next

Is there a way to combine A and B into One qury ? Any help please ...

+3  A: 

Well, really B is a single query. Remember that what comes back from a Linq statement is an IQueryable, not the actual result. This means that B combines its own expressions with that of A, but retrieval is not performed until you enumerate B. So B really is just a single query.

spender