I have a table which has a column for Id and parentId. ParentId contains the Id of another row in the table. If the ParentId is null then it is the top of the hierarchy.
I have the Id of a row and I want to select all rows above it in the hierarchy. Can I do this in a single select?
so in this example:
Id | parentId | other columns
1 | null
2 | 1
3 | 2
if I have id=3 I want to select rows 1,2,3.
Can I do it in linq to sql?