I have an employee class that has an employeeId (int), parent(int) and children property List. I get the employee list from the database in the
List
List allEmployees = new List(); allEmployees.AddRange(LoadAllEmployees()); // pull from DB in flat format foreach (var employee in allEmployees) { employee.Children = allEmployees.Where(e => e.ParentId == employee.EmployeeId).ToList(); }