<分区>
假设我们有如下三个 Dbset:
Category
{
...
public virtual ICollection<Item> Items {get; set;}
...
}
Item
{
...
public virtual ICollection<Specification> Specifications{get; set;}
...
}
Specification
{
...
}
对于预加载,我是这样使用的:
Category cat = db.Categories.Include(c=> c.Items).FirstOrDefault(c=> c.Id == 1);
但是现在的问题是
cat.Items[0].Specifications
为null
,我们如何让它也能预先加载集合的子集合?
P.S.:我尝试删除 virtual
关键字进行测试(我不想删除它)但它也没有用。