diff --git a/XCode/Tree/EntityTree.cs b/XCode/Tree/EntityTree.cs index 224b5d620..feb847ea7 100644 --- a/XCode/Tree/EntityTree.cs +++ b/XCode/Tree/EntityTree.cs @@ -288,8 +288,9 @@ public static IList FindAllParentsByKey(TKey key) /// 根节点 /// 返回列表是否包含根节点,默认false /// 要排除的节点 + /// 深度。仅返回指定深度层级的节点 /// - protected static IList FindAllChilds(IEntityTree entity, Boolean includeSelf = false, IEntityTree? exclude = null) + public static IList FindAllChilds(IEntityTree entity, Boolean includeSelf = false, IEntityTree? exclude = null, Int32 depth = -1) { if (entity == null) return []; var childlist = entity.Childs; @@ -321,7 +322,7 @@ protected static IList FindAllChilds(IEntityTree entity, Boolean includ // 已进入待处理队列的,不再处理 if (stack.Contains(childs[i])) continue; - stack.Push(childs[i]); + if (depth < 0 || childs[i].Deepth <= depth) stack.Push(childs[i]); } } //// 去掉第一个,那是自身