背景:
主流程表中包含员工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();
PS:select new之后一定要加对应的类名,不然返回后就是对象转换时会有问题
原文地址:https://www.cnblogs.com/yhnet/p/11975852.html
时间: 2024-11-10 14:52:43