public IList <DatumClass> GetDatumClass(int rootTypeId) { List <DatumClass> list = new List <DatumClass>(); List <EPMDatumClass> all = new EPMDatumClassService().ToList <EPMDatumClass>(); DatumClass item = (from d in all where d.TypeId == rootTypeId select new DatumClass { Id = d.TypeId.ToString(), Text = d.TypeName, State = "open" }).FirstOrDefault <DatumClass>(); list.Add(item); this.AddChildren(item, all); return(list); }
private void AddChildren(DatumClass theDatum, IList <EPMDatumClass> all) { List <DatumClass> source = (from d in all where d.ParentId == Convert.ToInt32(theDatum.Id) select new DatumClass { Id = d.TypeId.ToString(), Text = d.TypeName, State = "open" }).ToList <DatumClass>(); for (int i = 0; i < source.Count <DatumClass>(); i++) { if (theDatum.Children == null) { theDatum.Children = new List <DatumClass>(); } theDatum.Children.Add(source[i]); this.AddChildren(source[i], all); } }