Counting percent of rows with category out of total number of rows using Dynamic Linq
问题 How to achieve this using Dynamic Linq Join and Dynamic Linq SelectMany 回答1: Desired result is in q and q2. q shows combination of aggregates from different levels of grouping in one expression. q2 uses calculated agg from prev levels and generates shorter SQL query. var grp=(db.A as IQueryable).GroupBy("grp","it"); var grp2=grp.Select("new(key as key,new(count() as cnt) as agg)"); foreach(dynamic r in grp2) Console.WriteLine("grp:"+r.key+"\tcnt:"+r.agg.cnt); //foreach(dynamic r in grp)