OData v4.0 aggregate queries (aggregate query syntax)

自古美人都是妖i 提交于 2019-12-11 06:35:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!