c# 递归函数使用案例
/// <summary> /// 递归查询 /// </summary> /// <param name="groupID"></param> /// <param name="idList"></param> protected static void FindChildrenID(int groupID, StringBuilder idList) {
// 这里是找孩子节点 var gLst = RepositoryFactory.Group.FindList(p => p.ParentID == groupID, "ID", false).ToList(); foreach (var item in gLst) { //判断子节点是否存在,有则继续 if (RepositoryFactory.Group.Find(p => p.ParentID == item.ID) != null) return FindChildrenID(item.ID, idList); idList.Append("|" + item.ID.ToString()); } }
文章属于个人工作备忘录,欢迎指正...