public List <WDT_ZzTj> ZzGroup(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, x.equip_ZzName }).Select(g => new { PqName = g.Key.equip_PqName, cjName = g.Key.equip_CjName, zzName = g.Key.equip_ZzName, ExceedNum = g.Sum(x => x.isExceed) }); List <WDT_ZzTj> r = new List <WDT_ZzTj>(); foreach (var item in a) { WDT_ZzTj tmp = new WDT_ZzTj(); tmp.pqName = item.PqName; tmp.cjName = item.cjName; tmp.zzName = item.zzName; tmp.tjNum = item.ExceedNum; r.Add(tmp); } return(r); } }
public List <WDT_ZzTj> ZzGroup(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, x.equip_ZzName }).Select(g => new { PqName = g.Key.equip_PqName, cjName = g.Key.equip_CjName, zzName = g.Key.equip_ZzName, ExceedNum = g.Sum(x => x.isExceed) }); List <WDT_ZzTj> r = new List <WDT_ZzTj>(); foreach (var item in a) { WDT_ZzTj tmp = new WDT_ZzTj(); tmp.pqName = item.PqName; tmp.cjName = item.cjName; tmp.zzName = item.zzName; tmp.tjNum = item.ExceedNum; r.Add(tmp); } return(r); } }