I have an Item
. Item
has a Category
.
Category
has ID
, Name
, Parent
and Children
. Parent
and Children
are of Category
too.
When I do a LINQ to Entities query for a specific Item
, it doesn't return the related Category
, unless I use the Include("Category")
method. But it doesn't bring the full category, with its parent and children. I could do Include("Category.Parent")
, but this object is something like a tree, I have a recursive hierarchy and I don't know where it ends.
How can I make EF fully load the Category
, with parent and children, and the parent with their parent and children, and so on?
This is not something for the whole application, for performance considerations it would be needed only for this specific entity, the Category.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…