Tuesday, March 15, 2011

EntityFramework ObjectQuery<T>.Include With Filter ability

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?

From stackoverflow
  • 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.

0 comments:

Post a Comment