How to generate dynamic LINQ queries with GroupBy and Aggregates (SUM, COUNT, AVG)? -
the following code generates dynamic linq queries simple .where clauses involving field , value. extend class able generate groupby , equivalent of "having sum(amountfield)" or "having count(field)". in essence should generate equivalent of: _people.groupby(c => c.name) .where(grp => grp.count() > 1) .select(grp => grp.key); or _orders.groupby(c => c.custid) .where(grp => grp.sum(x => x.amount) > 100) .select(grp => grp.key); can help? here code i'm using: public class expressioncriteria<t> { list<expressioncriterion> _expressioncriterion = new list<expressioncriterion>(); private string _andor = "and"; public expressioncriteria<t> and() { _andor = "and"; return this; } public expressioncriteria<t> or() { _andor = "or"; return this; }