Given the following:
public class Person
{
public int PersonId { get; set; }
public int? ParentId { get; set; }
}
Suppose I have the following tree structure (PersonID - ParentID):
1 - null
2 - 1
3 - 2
4 - 1
How can I get all the parents of PersonId 3
, or 2,1
using a LINQ to SQL query?
Note: A null
ParentId denotes a top-level Person