using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using FreeSql.Site.Entity; namespace FreeSql.Site.UI.Models { public class TreeData { public TreeData() { } public TreeData(DocumentType type) { this.id = type.ID; this.text = type.TypeName; } public TreeData(DocumentType type, List list) { this.id = type.ID; this.text = type.TypeName; this.children = (from l in list where l.UpID == type.ID select new TreeData(l, list)).ToList(); } /// /// 唯一编号 /// public int id { get; set; } /// /// 标题 /// public string text { get; set; } /// /// 类型 =0 表示类型 =1 表示内容 /// public int datatype { get; set; } = 0; public List children { get; set; } public TreeData AddChildrens(List list, Func> bind = null) { if (this.children != null && bind != null) { this.children.ForEach(f => { f.children = bind(f.id); }); } this.children?.AddRange(list); return this; } } }