当前位置:首页 > Web开发 > 正文

.net Linq多表组合查询结果集

2024-03-31 Web开发

主流程表中包含员工ID及流程类型ID,在页面查看流程是需要显示员工姓名及流程名称

操作:

//先进行分页处理原始数据 var result = from p in _dbContext.Set<BeWorkflowContent>() select p; if (searchWhere != null) result = result.Where(searchWhere); if (order != null) result = result.OrderByDescending(order); rowCount = result.Count(); //多表查询组装最后的数据模型 var query = from a in result join b in _dbContext.BeUser on a.UserId equals b.UserId join c in _dbContext.BeWorkflow on a.WorkflowId equals c.WorkflowId select new WorkFlowContentV() { CustomerName = a.CustomerName, WorkflowContentId = a.WorkflowContentId, CarType = a.CarType, CarStyle = a.CarStyle, CarLicense = a.CarLicense, UserName = b.TrueName, WorkflowName = c.WorkflowName }; return query.ToList();

View Code

PS:select new之后一定要加对应的类名,,不然返回后就是对象转换时会有问题

.net Linq多表组合查询结果集

标签:

原文地址:https://www.cnblogs.com/yhnet/p/11975852.html

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/41780.html