Reputation: 71
Is it possible to use $expand, skip and top in same odata query?
example : /product.svc/App('scscascscasc')/App?
$select=AppID,Platforms&$expand=Platforms&$format=json
Upvotes: 3
Views: 14954
Reputation: 2843
You can use any query options(one or more) in one odata v4 query.
It is server's decision about how to apply these query options.
"https://localhost:44348/api/Fabrikas?$expand=Orders($orderby($top=1)"
Upvotes: 0
Reputation: 11
Yes, it is possible to use $expand, skip and top in same odata query as shown below:
https://services.odata.org/V3/northwind/northwind.svc/Customers?$expand=Orders & $top=3 & $skip=3 & $format=json
This is the northwind service query which shows orders for customers. It skips the first 3 customers and displays data for next 3 customers.
Upvotes: 0
Reputation: 1098
According to OData Spec V4, $skip and $top are supported in $expand, but there is no specific items says that $expand supports mixed $stip and $top. http://services.odata.org/V4/TripPinService/Me?$expand=Friends($top=4) Can work per Spec.
Upvotes: 0
Reputation: 2995
You can use any query options(one or more) in one odata query.
It is server's decision about how to apply these query options.
For $expand, $skip and $top, it is possible and reasonable to use all of them in one odata query.
Such as HttpGet ~/Customers?$expand=Orders&$skip=5&$top=6
But in the end, such request needs support from server side as I said above.
Upvotes: 0
Reputation: 1195
As described in OData website
http://host/service/Products?$top=5&$skip=2
The set of expanded entities can be further refined through the application of expand options, expressed as a semicolon-separated list of system query options, enclosed in parentheses, see [OData-URL].
Allowed system query options are $filter, $select, $orderby, $skip, $top, $count, $search, $expand, and $levels.
Example 38: for each customer entity within the Customers entity set, the value of those associated Orders whose Amount is greater than 100 will be represented inline
http://host/service.svc/Customers?$expand=Orders($filter=Amount gt 100)
Upvotes: 4