首页 > 代码库 > Entity Framework Lambda 实现多列Group by,并汇总求和

Entity Framework Lambda 实现多列Group by,并汇总求和

 

 

var result = DataSummaryRepository.FindBy(x => x.UserID == argMemberNo && x.SummaryDate <= argEndDate && x.SummaryDate >= argStarDate).OrderByDescending(x => x.SummaryDate).GroupBy(x => new { x.SummaryDate, x.UserID }).Select(g => new            {                PV = g.Sum(x => x.PV),                UV = g.Sum(x => x.UV),                OrderQunantity = g.Sum(x => x.OrderQunantity),                OrderAmount = g.Sum(x => x.OrderAmount),                CommissionEstimate = g.Sum(x => x.CommissionEstimate),                AvaliableCommission = g.Sum(x => x.AvaliableCommission),                HistoryCommission = g.Sum(x => x.HistoryCommission),                SummaryDate = g.Key.SummaryDate,                UserID = g.Key.UserID            });
View Code