Find Full path all the Child node
-
I am having table in Parent Child relation as following:
ID Node Name ParentID
1 Node 1 0
2 Node 2 0
3 Node 21 2
4 Node 22 2
5 Node 21 1 3
6 Node 3 0
7 Node 4 0
8 Node 41 7I want the to write the all the child node as following output using the Entity Framework (not code Firt) or using simple dataTable. Expected Output:
Node 1
Node 2 > Node 21 > Node 21 1
Node 2 > Node 22
Node 3
Node 4 > Node 41Thanks, Rohit
-
I am having table in Parent Child relation as following:
ID Node Name ParentID
1 Node 1 0
2 Node 2 0
3 Node 21 2
4 Node 22 2
5 Node 21 1 3
6 Node 3 0
7 Node 4 0
8 Node 41 7I want the to write the all the child node as following output using the Entity Framework (not code Firt) or using simple dataTable. Expected Output:
Node 1
Node 2 > Node 21 > Node 21 1
Node 2 > Node 22
Node 3
Node 4 > Node 41Thanks, Rohit
I think you can achieve through the self join, please follow below query:
var query =
from e1 in Employee
join e2 in Employee on e1.ManagerID equals e2.ID
select new
{
Employee = e1.FirstName + " " + e1.LastName,
Manager = e2.FirstName + " " +e2.LastName
};Parwej Ahamad
-
I think you can achieve through the self join, please follow below query:
var query =
from e1 in Employee
join e2 in Employee on e1.ManagerID equals e2.ID
select new
{
Employee = e1.FirstName + " " + e1.LastName,
Manager = e2.FirstName + " " +e2.LastName
};Parwej Ahamad