sqlsugar 树型递归查询。UtilMethods.BuildTree 用法 电脑版发表于:2024/11/7 15:26 sqlsugar 树型递归查询官方文档: https://www.donet5.com/home/doc?masterId=1&typeId=2311 ### UtilMethods.BuildTree 用法 ``` public class Tree { [SqlSugar.SugarColumn(IsPrimaryKey = true)] public int Id { get; set; } public string Name { get; set; } public int ParentId { get; set; } public List<Tree> Child { get; set; } } // 假设已经从数据库查询得到一个Tree实体的列表list var tree = UtilMethods.BuildTree(db, list, "Id", "ParentId", "Child", 0); ```