Does anyone know how to get a groupby count from a dynamic query? I can group by a field, I just can't get it's count without pulling all the records down. I just want the group field and how many there are.
This works, but only returns the key.
var selector = new AnonymousProjectionSelector().Combine("Key");
This does not. I was only guessing anyway.
var selector = new AnonymousProjectionSelector().Combine("Key").Combine("Key.Count","Count");
Code
public void ReadDistinctValuesAndCounts(object sender, QueryGroupsEventArgs e)
{
var query = BuildWhereClause(e.CollectionView, e.GroupPath, _baseQuery);
query = BuildSortClause(e.CollectionView, query);
var groupByField = e.ChildGroupPropertyName;
var groupBy = new ProjectionSelector(groupByField);
var selector = new AnonymousProjectionSelector().Combine("Key");
ITypedEntityQuery groupByQuery = query.GroupBy(groupBy).Select(selector);
var result = groupByQuery.Execute();
}