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)
};
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)
};