public List <WDT_CjTj> CjGroup(int Id) { using (var db = base.NewDB()) { var a = db.A6dot2Tab2.Where(x => x.isValid == 1 && x.isOilType == 1 && x.Tab1_Id == Id).GroupBy(x => new { x.equip_PqName, x.equip_CjName }).Select(g => new { PqName = g.Key.equip_PqName, cjName = g.Key.equip_CjName, ExceedNum = g.Sum(x => x.isExceed) }); List <WDT_CjTj> r = new List <WDT_CjTj>(); foreach (var item in a) { WDT_CjTj tmp = new WDT_CjTj(); tmp.pqName = item.PqName; tmp.cjName = item.cjName; tmp.tjNum = item.ExceedNum; r.Add(tmp); } return(r); } }
public List <WDT_CjTj> CjGroup(string starttime, string endtime) { using (var db = base.NewDB()) { var a = db.A6dot2Tab2.Where(x => x.isValid == 1 && x.isOilType == 1 && x.Tab1_Belong.uploadtime.CompareTo(starttime) >= 0 && x.Tab1_Belong.uploadtime.CompareTo(endtime) <= 0).GroupBy(x => new { x.equip_PqName, x.equip_CjName }).Select(g => new { PqName = g.Key.equip_PqName, cjName = g.Key.equip_CjName, ExceedNum = g.Sum(x => x.isExceed) }); List <WDT_CjTj> r = new List <WDT_CjTj>(); foreach (var item in a) { WDT_CjTj tmp = new WDT_CjTj(); tmp.pqName = item.PqName; tmp.cjName = item.cjName; tmp.tjNum = item.ExceedNum; r.Add(tmp); } return(r); } }