I want to create a linq dynamic query using group by and aggregate function like sum on different column of same table. i am using entity framework and using one table for one query.
like below but its showing error at runtime , its not correct way to right. Please tell me how to write a correct linq query.
Query --->
var varWeldingProgressReport = context.WeldingAuditProgressReports.Where(strWhereClause).Where(i => i.ReportDt >= dtDateFrom && i.ReportDt <= dtDateTo).Select("new(" + varAggregateColWeldingAudit + ")");
var temp = context.WeldingAuditProgressReports.GroupBy("ReportDt", "it").Select("new(Key as ReportDt, Sum(Progress) as Total)");
Linq query with group by & aggregate function like sum.
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Jan 5, 2014, 11:19 PM EST
Chetan Khokha12 reputationPosted Jan 5, 2014, 11:45 PM EST
Nicolas Lips2 reputationPosted Feb 11, 2014, 11:36 PM EST
AdaptiveLINQ provide the QueryByCube extension method for any IQueryable collection.
QueryByCube acts as a "GroupBy + Aggregation" where grouping key selectors (the dimensions of the cube notion) are determined at runtime.