linq分组统计

来源:互联网 发布:淘宝u站9.9包邮官网 编辑:程序博客网 时间:2024/06/07 18:21
                    var query =  from a in db.ThinkTelCSVTable
                                 from b in db.ThinkTelCDRTable
                                 where a.CSVID == b.CSVID &&
                                 b.Field4 < b.Field1 &&
                                 b.CSVDate >= startDate
                                 group b by new
                                 {
                                     a.CSVDate,
                                     a.CSVName
                                 } into g
                                 orderby g.Key.CSVDate descending
                                 select new
                                 {
                                     CSVDate = g.Key.CSVDate,
                                     CSVName = g.Key.CSVName,
                                     ExceptionCount = g.Count(),
                                     TeraGoCost = g.Sum(t => t.Field1),
                                     ClientCost = g.Sum(t => t.Field4)
                                 };
原创粉丝点击