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;


            }

  • 相关阅读:
    仿百度翻页(转)
    文字顺时针旋转90度(纵向)&古诗词排版
    微信小程序使用canvas绘制图片的注意事项
    PHP即时实时输出内容
    使用Android Studio遇到的问题
    RuntimeError: Model class users.models.UserProfile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
    drf中的各种view,viewset
    代码审计:covercms 1.6
    windows下安装phpredis扩展
    python练习:异常
  • 原文地址:https://www.cnblogs.com/LuoEast/p/9696879.html
Copyright © 2011-2022 走看看