zoukankan      html  css  js  c++  java
  • C# 递归模型定义。赋值

    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;


            }

  • 相关阅读:
    C#小数点位数处理方法
    C#获取硬盘空间信息
    Linux双网卡绑定实现负载均衡
    CentOS、Ubuntu配置网卡子接口
    CentOS7修改网卡名称,禁用ipv6
    centos命令自动补全增强
    使用批处理文件访问ORACLE数据库
    Mac 常用终端命令
    常用正则表达式
    pickle 模块
  • 原文地址:https://www.cnblogs.com/LuoEast/p/9696879.html
Copyright © 2011-2022 走看看