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

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

        
    }

  public IActionResult ListProductType()
        {
            List<Models.ProductTypeModel> listType = new List<Models.ProductTypeModel>();
          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<Models.ProductTypeModel> subListProductType(long fid)
        {
            var dbProductTypeInfo = typeBll.Query(x => x.IsDelete == false && x.Fid == fid);
            List<Models.ProductTypeModel> listType = new List<Models.ProductTypeModel>();
            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;


        }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-24
  • 2022-12-23
  • 2021-06-07
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案