C# Linq 查询汇总(持续更新)
2022/3/3 20:17:41
本文主要是介绍C# Linq 查询汇总(持续更新),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 var resultlist = orderllist.GroupBy(oo => new { oo.Deptname, oo.Userid, oo.Username }) 2 .Select(ss => new OBreakfirstModel 3 { 4 Number = number++, 5 Deptname = ss.Key.Deptname, 6 Userid = ss.Key.Userid, 7 Username = ss.Key.Username, 8 Ototalamount = ss.Sum(s => s.Ototalamount), 9 Ocount = ss.Sum(s => s.Ocount) 10 });
1 var danzilist = DBconn.Query<ZuZModel>(sql_list, dynamicParameters).ToList(); 2 var zijianlist= DBconn.Query<ZiMX>(sql_jian).ToList(); 3 var resultlist = (from danzi in danzilist 4 select new ZuZhuangCXModel() 5 { 6 fid = danzi.fid, 7 rukurq=danzi.rukurq, 8 shiwulx=danzi.shiwulx, 9 wuliaobm=danzi.wuliaobm, 10 wuliaomc=danzi.wuliaomc, 11 wuliaolbdm=danzi.wuliaolbdm, 12 wuliaolbmc=danzi.wuliaolbmc, 13 shuliang=danzi.shuliang, 14 cangkuid=danzi.cangkuid, 15 cangkumc=danzi.cangkumc, 16 zijianmxs = (from zijian in zijianlist 17 where zijian.fid == danzi.fid 18 select new ZiJianMX() 19 { 20 fid = zijian.fid, 21 fdetailid = zijian.fdetailid, 22 wuliaobm = zijian.wuliaobm, 23 wuliaomc = zijian.wuliaomc, 24 cangkuid = zijian.cangkuid, 25 cangkumc = zijian.cangkumc, 26 shuliang = zijian.shuliang 27 }).ToList() 28 }).ToList();
var newycmxlist = ycmxlist.GroupBy(g => new { g.EMPI, g.SHIFOUXZ }) .Select(item => item.First()).ToList();
List<YiChangEMPIModel> ycmxlist = new List<YiChangEMPIModel>(); var yichang = from yc in AnalysisDbContext.EMPI_YC from ycmx in AnalysisDbContext.EMPI_YCMX where yc.ID == ycmx.ZHUBIAOID && (state == "*" ? 1==1: yc.SHIFOUXZ==state) && (yc.EMPI.Contains(text) || ycmx.SHENFENZH.Contains(text) || ycmx.XINGMING.Contains(text)) orderby yc.UPDATE_TIME descending select new { ID=yc.ID, EMPI=yc.EMPI, SHIFOUXZ=yc.SHIFOUXZ, INSERT_TIME=yc.INSERT_TIME, UPDATE_TIME=yc.UPDATE_TIME }; foreach (var yc in yichang) { ycmxlist.Add(new YiChangEMPIModel { ID = yc.ID, EMPI = yc.EMPI, SHIFOUXZ = yc.SHIFOUXZ, INSERT_TIME = yc.INSERT_TIME, UPDATE_TIME = yc.UPDATE_TIME }); }
//部门信息 关联 日志表 取出上次处理时间 //deptresult:包含各级部门和上传时间 var deptresult = (from t1 in dapartments join t2 in logs on t1.DeptID equals t2.DeptID into temp from tempresule in temp.DefaultIfEmpty( new SendLogModel { Starttime = Convert.ToDateTime("2020-12-22"), Endtime = Convert.ToDateTime("2020-12-22") }) select new DepartmentInfoModel { CurntDeptID = t1.CurntDeptID, CurntDeptName = t1.CurntDeptName, DeptID = t1.DeptID, DeptName = t1.DeptName, LeaderID = t1.LeaderID, LeaderName = t1.LeaderName, Starttime = tempresule.Starttime, Endtime = tempresule.Endtime }).ToList();
//部门信息 关联 日志表 取出上次处理时间 //deptresult:包含各级部门和上传时间 var deptresult = (from t1 in dapartments join t2 in logs on t1.DeptID equals t2.DeptID into temp from tempresule in temp.DefaultIfEmpty( new SendLogModel { Starttime = Convert.ToDateTime("2020-12-22"), Endtime = Convert.ToDateTime("2020-12-22") }) select new DepartmentInfoModel { CurntDeptID = t1.CurntDeptID, CurntDeptName = t1.CurntDeptName, DeptID = t1.DeptID, DeptName = t1.DeptName, LeaderID = t1.LeaderID, LeaderName = t1.LeaderName, Starttime = tempresule.Starttime, Endtime = tempresule.Endtime }).ToList();
List<TemplistExpenseModel> currentlist = templistExpenseModels; if (userid != "" && userid != null) { currentlist.Where(ee => ee.Userid == userid).ToList().ForEach(cc => { templistExpenseModels.Remove(cc); }); return Json(new { code = 200, msg = "清除推送列表成功!" }); }
这篇关于C# Linq 查询汇总(持续更新)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#
- 2024-01-24Advanced .Net Debugging 1:你必须知道的调试工具