对具有聚合OData版本4的Apply的结果执行OrderBy [英] Perform OrderBy on the results of Apply with Aggregate OData Version 4
问题描述
考虑我有一个像这样的odata查询:
Consider I have an odata query like this:
Sessions?$apply=filter(SomeColumn eq 1)/groupby((Application/Name), aggregate(TotalLaunchesCount with sum as Total))
会话和应用程序实体通过ApplicationId链接.我想在总计"上应用orderby,并获得odata查询响应的前5个结果.
Sessions and Application entities are linked by ApplicationId. I want to apply orderby on "Total" and get top 5 results as odata query response.
我尝试在上述查询的末尾添加&$top=5
.它说:
I tried adding &$top=5
at the end of the above mentioned query. Its says:
URI中指定的查询无效.在会话"类型上找不到名为总计"的属性.
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?
推荐答案
受支持. $ skip,$ top,$ orderby是根据$ apply链的结果执行"的. 在这种情况下,查询应如下所示:
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