Perform OrderBy on the results of Apply with Aggre

2019-07-31 04:22发布

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条回答
祖国的老花朵
2楼-- · 2019-07-31 04:32

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

查看更多
登录 后发表回答