Not sure if recursive is the right word, but here's the situation:
Using AdventureWorks, LINQPad, and the Employee table.
An Employee has a ManagerID column. If the value is NULL then that Employee has
no manager.
What I want to do is select the top-level employee, his/her subordinates, and
for each of those their subordinates, and so on.
Var query = from mgr in Employees
Where mgr.ManagerID == null
Select new
{
Title = mgr.Title,
Subordinates = from person in
Employees
Where person.ManagerID = mgr.EmployeeID
Select new { Title = person.Title }
};
This gets me one level deep. But I'd like to see how it can be written to go
deeper until eventually I arrive at an Employee who no subordinate.
Hope that makes sense and looking forward to any info.
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com