我有一个数据结构,其中User有UserPlans,UserPlans有计划。我已经为System.Data.Entity添加了一个using语句,这样我就可以强力键入我的包含,但是我无法弄清楚是否有一种方法可以强力键入一个包含多个包含的包含关系深层次。所以我有:
from user in entities.Users.Include(u => u.UserPlans).Include("UserPlans.Plans")
但我希望能够做到这样的事情:
from user in entities.Users.Include(u => u.UserPlans).Include(u => u.UserPlans.Include(up => up.Plan))
为了不在我的include中包含字符串。有办法吗?
答案 0 :(得分:2)
之前已经回答过:EF CTP5 - Strongly-Typed Eager Loading - How to Include Nested Navigational Properties?
基本上:
from user in entities.Users.Include(u => u.UserPlans.Select(p => p.Plans))