public static void Factorial(List <TS_DEPTDTO> dtos, List <DEPTDTO> newDtos) { foreach (var o in dtos) { DEPTDTO newDto = new DEPTDTO(); newDto.id = o.C_ID; newDto.text = o.C_NAME; newDtos.Add(newDto); if (o.Depts.Count > 0) { Factorial(o.Depts, newDto.nodes); } } }
/// <summary> /// 部门列表 /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="T2"></typeparam> /// <param name="t"></param> /// <param name="tt"></param> /// <returns></returns> public static List <DEPTDTO> ConvertDept(List <TS_DEPTDTO> old) { List <DEPTDTO> newDtos = new List <DEPTDTO>(); if (old.Count > 0) { foreach (var o in old) { DEPTDTO newDto = new DEPTDTO(); newDto.id = o.C_ID; newDto.text = o.C_NAME; newDtos.Add(newDto); if (o.Depts.Count > 0) { Factorial(o.Depts, newDto.nodes); } } } return(newDtos); }