Reputation: 609
I have a self referencing table named categories that has a parentcategoryid column that is nullable.
When I added the table to the entity designer it created two navigation properties for this relationship and I named one ParentCategory (the zero or 1 nav prop) and the other I named SubCategories (the * many nav prop).
Everything works great except when I go more than one level deep it doesn't pick up the deeper levels.
So I get all the Category.SubCategories but I don't get the categories under the subcategories.
Am I missing something? starting to think I should have stuck with NHibernate. Shouldn't the deeper levels get lazy loaded?
return from c in _entities.ContentCategorySet.Include("SubCategories")
where c.ParentCategory == null
orderby c.Importance, c.Title
select c;
Upvotes: 2
Views: 928
Reputation: 609
OK, At least part of the problem is
where c.ParentCategory == null
When I remove that I get the deeper levels but then have subcategories on the top level. I guess I can just filter them out after the fact.
Upvotes: 1
Reputation: 10638
That's how I would Imagine the SubCategories property to behave.
Level 1
++ Level 2
++ Level 2
++ ++ Level 3
Where SubCategories property of Level 1 only returns Level 2 items. Then to get to Level 3 you would access the consecutive Level 2 items, in a recursive method.
Upvotes: 1