For Count it can be written as following:

private List GenerateImpl(IList myList, string field)
    IQueryable queryableList = myList.AsQueryable();
    IQueryable groupedList = queryableList.GroupBy(field,"it").
                            OrderBy("Key descending").
                            Select("new (Key as Key, Count() as Count)");

    // Note: IQueryable doesn't have ToList() implementation - only IEnumerable 
    return output.ToList(); // will not work

For List - possible you'll need to add your custom implementation to DynamicLibrary... See how it was done for Contains() method here


A solution is to use the .QueryByCube LINQ extension method provided by my product AdaptiveLINQ.

Disclaimer: I'm the AdaptiveLINQ developer

Related Articles