递归获取所有子孙节点

private void GetCategoryTreeNodes(List<FormTemplateCategory> allList,string rowGuid,ref List<FormTemplateCategory> treeNodes)
        {
            if (allList == null)
                return;
            List<FormTemplateCategory> 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);
            }
        } 

  

posted @ 2018-09-05 17:30  HongEgg  阅读(980)  评论(0编辑  收藏  举报