Пример #1
0
 public void Add(prod_category record)
 {
     Traverse()
     .First(node => node.category_id == record.paerent_category)
     .Children
     .Add(new prod_category_tree(record.category_name,
                                 record.category_id,
                                 (int)record.paerent_category)
          );
 }
Пример #2
0
        public static prod_category_tree CreateTree(List <prod_category> records)
        {
            prod_category rootRecord = records.First(r => r.paerent_category == 0);
            var           root       = new prod_category_tree(rootRecord.category_name, rootRecord.category_id, (int)rootRecord.paerent_category);

            foreach (prod_category record in records.Where(r => r.paerent_category != 0))
            {
                root.Add(record);
            }
            return(root);
        }