Ajay B L
Ajay B L

Reputation: 1106

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

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?

Upvotes: 2

Views: 3162

Answers (1)

donMateo
donMateo

Reputation: 2394

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

Upvotes: 1

Related Questions