EntityFramework Include (Eager Load) virtual property of virtual property
Imagine we have three Dbsets as shown below:
Category
{
...
public virtual ICollection<Item> Items {get; set;}
...
}
Item
{
...
public virtual ICollection<Specification> Specifications{get; set;}
...
}
Specification
{
...
}
For active loading, I use it like this:
Category cat = db.Categories.Include(c=> c.Items).FirstOrDefault(c=> c.Id == 1);
but now the problem is that
cat.Items[0].Specifications
is null
. How can we make it also load the collection's subplots?
PS: I tried to remove the virtual
test keyword (I don't want to remove it) but it doesn't work either.
+3
source to share