问题
For example, I have an object model:
Product
{
int ProductId,
string Name,
List<Sale> Sales
}
- I want to use the aggregate queries to get total Amount of Sales:
GET: Product?$apply=groupby(Name, aggregate(Sales(Amount with sum as Total))) (follow as oasis-open standard)
--> Got error: UriQueryExpressionParser_CloseParenOrCommaExpected=" ')' or ',' expected at position {0} in '{1}'. ". position at Amount.
- I change the query to:
GET: Product?$apply=groupby(Name, aggregate(Sales/Amount with sum as Total))
--> Work successfully!.
My question:
--> Had current version OData Core supported the aggregate query syntax as my example "aggregate(Sales(Amount with sum as Total))" or NOT?
Please give me your advice.
Thank you very much
回答1:
This is tracked at https://github.com/OData/odata.net/issues/463
The query
Product?$apply=groupby(Name, aggregate(Sales/Amount with sum as Total))
should throw exception as well, it's not supported yet.
回答2:
A solution is to use the QueryByCube
function provided by the AdaptiveLINQ component.
Disclaimer: I'm the AdaptiveLINQ developer
来源:https://stackoverflow.com/questions/39009270/odata-v4-0-aggregate-queries-aggregate-query-syntax