I currently have an OData V4 service that has the following model.
"Category" -- "Codes"
For each category there can be many codes.
I need to $expand the Codes, $filter where Active = true and then $orderby Codes.Description.
Currently the following works fine without ordering.
odata/Categories?$expand=Codes($filter=Active eq true)
This does not work.
odata/Categories?$expand=Codes($filter=Active eq true&$orderby=Description)
I receive "The query specified in the URI is not valid. Syntax error at position 12." & "Syntax error at position 12 in 'Description)'."
Basically it is reading the last ")" after "Description" as an error.
I was not able to find this in the OData V4 documents but I did find a similar example here "How can I order objects according to some attribute of the child in OData?"
http://services.odata.org/V4/Northwind/Northwind.svc/Orders?$select=OrderID&$expand=Order_Details($select=UnitPrice;$orderby=Quantity)
The key I was missing is
;
This goes between the filter and orderby.
Here is the working url
odata/Categories?$expand=Codes($filter=Active eq true;$orderby=Description)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With