I have a table structure like this.
id | Name | ParentId so for example:
id | Name | ParentId
1 | Alice | 0 2 | Bob | 0 3 | Charlie | 1 4 | David | 2
where 'Alice' and 'Bob' are Parent nodes( which has Id = 0) and Alice has a child node named 'Charlie' and 'Bob' has a child node named 'David'. My question is, I need to retrieve the parent separately and the children in a collection. The 'Children' collection can have multiple parents and its children. Can anyone send me a code snippet using which I can retrieve Data from the database and populate the tree.