views:

582

answers:

1

Hi, I'm using ObjectQuery.CreateQuery() to create eSQL query. I want to use the ObjcetQuery.Include to load related data, like Customer => Orders so let the EF to load all the orders for customer at the same time. The issue is that i don't want all the related objects and i want to fetch the result with condition.

Any idea?

A: 

Include will not work if you intend to materialize a master entity (Customer) with only some of the related child entities (Orders). The Entity Framework will not materialize a partially-complete type. Instead, I would recommend projecting into a new, anonymous type. Then you can include whichever Orders you like.

Craig Stuntz