为相关集合中的每个实体加载相关实体

时间:2013-08-30 10:14:46

标签: linq-to-sql entity-framework-4

public class Parent
{
   public IList<Child> Collection { get; set; }
}

public class Child
{
   public GrandChild GrandChild { get; set; }
}

public class GrandChild
{
   public string Value { get; set; }
}

Context.Parents.Select(p => new { Parent = p, Collection = p.Collection } );

查询获取每个父级的集合。但是如何为每个集合中的每个孩子加载GrandChild?

1 个答案:

答案 0 :(得分:0)

只需添加另一个。选择父级的末尾。选择