C# 递归模型定义。赋值

2021-07-09 19:06

阅读:381

标签:als   art   sort   模型   for   return   date   stty   csdn   

https://blog.csdn.net/wumiju/article/details/80429412

 public partial class ProductTypeModel:DbEntityModels.ProductType
    {
        public List SubProductTypeInfo { get; set; }

        
    }

  public IActionResult ListProductType()
        {
            List listType = new List();
          var  info = typeBll.Query(x => x.IsDelete == false && x.Fid == 0 && x.Depth == 0);
            foreach (var item in info)
            {
                listType.Add(new Models.ProductTypeModel()
                {
                    ID = item.ID,
                    IsDelete = item.IsDelete,
                    Depth = item.Depth,
                    CreateDate = item.CreateDate,
                    Fid = item.Fid,
                    Remark = item.Remark,
                    Sort = item.Sort,
                    TypeName = item.TypeName,
                    SubProductTypeInfo= subListProductType(item.ID)
                });
            }
            return Json(new { data = listType });
        }

        public List subListProductType(long fid)
        {
            var dbProductTypeInfo = typeBll.Query(x => x.IsDelete == false && x.Fid == fid);
            List listType = new List();
            foreach (var item in dbProductTypeInfo)
            {
                listType.Add(new Models.ProductTypeModel()
                {
                    ID = item.ID,
                    IsDelete = item.IsDelete,
                    Depth = item.Depth,
                    CreateDate = item.CreateDate,
                    Fid = item.Fid,
                    Remark = item.Remark,
                    Sort = item.Sort,
                    TypeName = item.TypeName,
                    SubProductTypeInfo = subListProductType(item.ID)
                });
            }
            return listType;


        }

C# 递归模型定义。赋值

标签:als   art   sort   模型   for   return   date   stty   csdn   

原文地址:https://www.cnblogs.com/LuoEast/p/9696879.html


评论


亲,登录后才可以留言!