I need to create dynamic lambda expression predicate for below query to query in Cosmos DB.
*select City, COUNT(City) as CityCount FROM Cities where status="Active"
group by City*
Earlier I have created for equal operation like this
var parameter = Expression.Parameter(typeof(T), "t");
MemberExpression expBody = Expression.Property(parameter, columnName);
But for getting Count and for Group By Clause how to do this.
I am not familiar with CosmoDB, but wouldn't LINQ be easier for this?
EDIT:
Examples to my answer in the comments ->
Taking the additional option to build these generically into account, you can build predicates quite dynamically with LINQ. I may be missing what you are trying to do, but I don't see any advantage in the usage of Expression Trees here.
The IQueryProvider<> of CosmoDB is already translating all the Queries for you, so unless I am unaware of something, you are writing unnecessary and possibly less optimized implementations by mapping Expressions to Queries yourself.