递归获取所有子孙节点

private void GetCategoryTreeNodes(List allList,string rowGuid,ref List treeNodes)
        {
            if (allList == null)
                return;
            List subList;
            subList = allList.Where(p => p.ParentRowGuid == rowGuid).ToList();
            if (!subList.Any())
                return;
            foreach(FormTemplateCategory item in subList)
            {
                treeNodes.Add(item);
                GetCategoryTreeNodes(allList, item.RowGuid, ref treeNodes);
            }
        } 

  

转载于:https://www.cnblogs.com/wangzuofei/p/9593412.html

你可能感兴趣的:(递归获取所有子孙节点)