private static int ResolveDeptCollection(List<Dept> dbDepts, Dept parentDept, int level) { int count = 0; foreach (var dept in dbDepts.Where(d => d.Parent == parentDept)) { count++; _depts.Add(dept); dept.TreeLevel = level; dept.IsTreeLeaf = true; dept.Enabled = true; level++; // 如果这个节点下没有子节点,则这是个终结节点 int childCount = ResolveDeptCollection(dbDepts, dept, level); if (childCount != 0) { dept.IsTreeLeaf = false; } level--; } return count; }
public object Clone() { Dept dept = new Dept { ID = ID, Name = Name, Remark = Remark, SortIndex = SortIndex, TreeLevel = TreeLevel, Enabled = Enabled, IsTreeLeaf = IsTreeLeaf }; return dept; }