Question

I have a table with this structure :

 create table shajare (
    node hierarchyid PRIMARY KEY CLUSTERED ,
level AS node.GetLevel() PERSISTED,
person_id int Unique,
person_name Nvarchar(30) Not null);

and I use this in SQL Server to show all children of a given parent:

select * 
from shajare as parent
inner join shajare as child on child.node.IsDescendantOf(parent.node) = 1
where parent.person_id = 12      

How can I show the children of a parent in a tree view by do not using recursive function or using some thing like that SQL code but by linq ? My boss asked for linq???

Please !!

Était-ce utile?

La solution

See my answer here to get a parent and all children/grand children and so on back from a sql query (will return the complete tree structure).

https://stackoverflow.com/a/14764333/853295

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top