Perform OrderBy on the results of Apply with Aggregate OData Version 4

我只是一个虾纸丫 提交于 2019-12-11 08:05:57

问题


Consider I have an odata query like this:

Sessions?$apply=filter(SomeColumn eq 1)/groupby((Application/Name), aggregate(TotalLaunchesCount with sum as Total))

Sessions and Application entities are linked by ApplicationId. I want to apply orderby on "Total" and get top 5 results as odata query response.

I tried adding &$top=5 at the end of the above mentioned query. Its says:

The query specified in the URI is not valid. Could not find a property named 'Total' on type 'Sessions'.

Can anyone tell me if such query is supported?


回答1:


It is supported. $skip, $top, $orderby are "performed" on result from $apply chain. In this case query should looks like this:

Sessions?$apply=filter(SomeColumn eq 1)
/groupby((Application/Name), aggregate(TotalLaunchesCount with sum as Total))
&$orderby=Total
&$top=5

3.15 Evaluating $apply



来源:https://stackoverflow.com/questions/47925722/perform-orderby-on-the-results-of-apply-with-aggregate-odata-version-4

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