I'm using Entity Framework 4.0 and I'm running into a problem with the following query:
IQueryable<user> users =
from u in Entities.users.
Include("orders_assigned").Include("orders_assigned.order_line_items")
from o in u.orders_assigned
where
o.status.Equals((int)OrderStatus.ReadyForInvestigation) &&
o.assigned_to_user_id != 0
from oli in o.order_line_items
where
oli.line_item_type.Equals("service") ||
oli.line_item_type.Equals("package_service")
select u;
I'm trying to return a list of users containing a sub list of their orders, containing a sub list of the order line items (something like user->orders->order_line_items) as shown by the includes above - however whenever I call ToTraceString
this query it shows only returning a list of users.
I've used Include
before with no problems, not sure what I'm doing wrong this time.
Try:
IQueryable<user> users = ((ObjectQuery<user>)
from u in Entities.users
from o in u.orders_assigned
where
o.status.Equals((int)OrderStatus.ReadyForInvestigation) &&
o.assigned_to_user_id != 0
from oli in o.order_line_items
where
oli.line_item_type.Equals("service") ||
oli.line_item_type.Equals("package_service")
select u).Include("orders_assigned").Include("orders_assigned.order_line_items");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.