2

I wired up my LinqPad to Entity Framework and was happily writing my query until I noticed that some of my objects were not in the result list.

I had a query that resembles this:

 IQueryable<IGrouping<Customer, Order>> myResults;
 myResults = Orders.Include("OrderDetail").GroupBy(x=>x.Customer);
 myResults.Dump(20);

When I ran that the Order.OrderDetail objects were not in the dump. (The data is there though. I ran some foreach statements to check and it was all in the resulting objects, just not being dumped.)

But if I just run this:

 Orders.Include("OrderDetail").Dump(20);

Then I get the OrderDetail objects in the dump.

Am I doing something wrong? Is it wrong to expect that LinqPad would dump my Include Objects even though there is a GroupBy going on?

Joe Albahari
  • 30,118
  • 7
  • 80
  • 91
Vaccano
  • 78,325
  • 149
  • 468
  • 850

1 Answers1

0

Seen something similar before. Did you try swapping the order of the groupby and include?

myResults = Orders.GroupBy(x=>x.Customer).Include("OrderDetail");
jenson-button-event
  • 18,101
  • 11
  • 89
  • 155
  • 1
    The `Include` method is not defined for the results of a `GroupBy`. (It needs an `ObjectQuery` and `GroupBy` returns an `IQueryable`.) – Vaccano Dec 13 '11 at 17:45