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# 递归模型定义。赋值的更多相关文章
- [MVC]自定义模型绑定器,从表单对模型进行赋值
一.奇葩的问题 之前自己造轮子的时候,遇到一个很奇怪的问题,虽然需求很奇葩,但是还是尝试解决了一下 当提交的表单里包含多个重复名称的字段的时候,例如 <form action="/Te ...
- Entity Framework 6 Recipes 2nd Edition(11-1)译 -> 从“模型定义”函数返回一个标量值
第11章函数 函数提供了一个有力代码复用机制, 并且让你的代码保持简洁和易懂. 它们同样也是EF运行时能利用的数据库层代码.函数有几类: Rowset Functions, 聚合函数, Ranking ...
- Entity Framework 6 Recipes 2nd Edition(11-2)译 -> 用”模型定义”函数过滤实体集
11-2. 用”模型定义”函数过滤实体集 问题 想要创建一个”模型定义”函数来过滤一个实体集 解决方案 假设我们已有一个客户(Customer)和票据Invoice)模型,如Figure 11-2所示 ...
- Entity Framework 6 Recipes 2nd Edition(11-2)译 -> 为一个”模型定义”函数返回一个计算列
11-3. 为一个”模型定义”函数返回一个计算列 问题 想从”模型定义”函数里返回一个计算列 解决方案 假设我们有一个员工(Employee)实体,属性有: FirstName, LastName,和 ...
- Entity Framework 6 Recipes 2nd Edition(11-4)译 -> 在”模型定义”函数里调用另一个”模型定义”函数
11-4.在”模型定义”函数里调用另一个”模型定义”函数 问题 想要用一个”模型定义”函数去实现另一个”模型定义”函数 解决方案 假设我们已有一个公司合伙人关系连同它们的结构模型,如Figure 11 ...
- Entity Framework 6 Recipes 2nd Edition(11-5)译 -> 从”模型定义”函数返回一个匿名类型
11-5. 从”模型定义”函数返回一个匿名类型 问题 想创建一个返回一个匿名类型的”模型定义”函数 解决方案 假设已有游客(Visitor) 预订(reservation)房间(hotel ) 的模型 ...
- Entity Framework 6 Recipes 2nd Edition(11-6)译 -> 从一个”模型定义”函数里返回一个复杂类型
11-6.从一个”模型定义”函数里返回一个复杂类型 问题 想要从一个”模型定义”函数返回一个复杂类型 解决方案 假设我们有一个病人(patient)和他们访客(visit)的模型,如 Figure 1 ...
- python基础学习1-变量定义赋值,屏幕输入输出
一.变量定义赋值 输入输出屏幕显示 : name = input("input is your name") age =int( input("input is your ...
- beego——模型定义
复杂的模型定义不是必须的,此功能用作数据库数据转换和自动建表 默认的表名规则,使用驼峰转蛇形: AuthUser -> auth_user Auth_User -> auth__user ...
随机推荐
- meta 跳转
强无敌. 是否厌倦了页面枯燥的跳转? 试试这样的跳转吧. Duration:表示滤镜特效的持续时间(单位:秒) Transition:滤镜类型.表示使用哪种特效,取值为0-23. <Meta h ...
- HDU1530 最大流问题
第一次写Dinic 然后贴一下 最基础的网络流问题 嘎嘎: #include <iostream> #include<cstdio> #include<string.h& ...
- multiprocessing 源码解析 更新中......
一.参考链接 1.源码包下载·链接: https://pypi.org/search/?q=multiprocessing+ 2.源码包 链接:https://pan.baidu.com/s/1j ...
- Axure RP Extension for Chrome修复
Axure RP Extension for Chrome安装之前一直用 Firefox 浏览器浏览原型文件,一直用不惯,而且用 Firefox 的唯一目的就是看原型.其他都是用 Chrome 浏览器 ...
- Base64图片编码原理,base64图片工具介绍,图片在线转换Base64
Base64图片编码原理,base64图片工具介绍,图片在线转换Base64 DataURI 允许在HTML文档中嵌入小文件,可以使用 img 标签或 CSS 嵌入转换后的 Base64 编码,减少 ...
- Codeforce 296A - Yaroslav and Permutations
Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring a ...
- [转载]基于UML的需求分析和系统设计(完整案例和UML图形演示)
小序: 从学生时代就接触到UML,几年的工作中也没少使用,各种图形的概念.图形的元素和属性,以及图形的画法都不能说不熟悉.但是怎样在实际中有效地使用UML使之发挥应有的作用,怎样捕捉用户心中的需求并转 ...
- 安装mysql警告 warning: mysql-community-server-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
摘自:https://www.cnblogs.com/royfans/p/7243641.html 红帽安装rpm安装MySQL时爆出警告: 警告:MySQL-server-5.5.46-1.linu ...
- Java用Jackson遍历json所有节点
<!-- jackson begin --> <dependency> <groupId>com.fasterxml.jackson.core</groupI ...
- li设置inline-block后,li左边出现空隙问题。
方法1:在ul设置font-size=0,然后再li再单独设置font-size 方法2:li连着写不要换行,也可以解决. <ul> <li>测试1</li>< ...