Determine if record has children in LINQ to SQL
I am having at hierarchical table with the structure ID, Name, FK_ID, Sortkey
Fetching the data in LINQ to SQL is straight forward:
var list = from ls in db.myTable
where ls.FK_ID == levelId
orderby ls.sortkey ascending
select ls;
And I can traverse down the tree by linking to the next levelId.
But what I can't figure out, if there is a way in LINQ, to check if there
is any children
I could probably build a view, that added a flag to each record, but I
would rather do this in LINQ, if possible.
What would even be the best practice for adding such a flag in SQL?
My idea on checking each record, is not the most performance friendly
solution.
No comments:
Post a Comment