我有一个employeeId(int),parent(int)和children属性List<Employee>
的雇员类。我以正确的顺序从数据库中获得员工名单,现在需要构建层次结构,但是我失败了......我知道这是编程101,但是我很难用它。平面数据的层次结构
public class Employee
{
public int EmployeeId { get; set;}
public int ParentId;{ get; set;}
public List<Employee> Children; { get; set;}
}
数据示例
EmployeeId, ManagerId
1, 0 //no one
2, 1
3, 1
4, 2
5, 2
6, 3
7, 3
你以建立层次试过什么?你可以发布你的代码和你遇到的问题吗? – Oded 2011-01-31 19:55:40
你的问题是什么?员工的孩子对什么有什么要求? – Qwertie 2011-01-31 19:56:20