Reputation: 1343
I'm trying to do some custom sorting in OData using this URL
localhost:82/odata.svc/ComponentPresentations?$filter=TemplateId eq 2894 and publicationId eq 10&$expand=Component/Keywords?$orderby=Title desc
Where Component
is a property of ComponentPresentation
and Keywords
is property of Component
, and I want to sort the ComponentPresentation according to the keyword's Title
attribute. But keywords nor title is a property of Component Presentation
Is there a way to sort the results according to the attribute of Keword's title? Which is a Child of Component, which is a child of ComponentPresentation?
Upvotes: 16
Views: 15795
Reputation: 83
append order by with expand object/field on the end of the query
localhost:82/odata.svc/ComponentPresentations?$filter=TemplateId eq 2894 and publicationId eq 10&$expand=Component/Keywords?$orderby=Component/Title desc
Upvotes: 2
Reputation: 13043
Just want to mention that it is possible since OData V4. You can nest as many expands/selects/orderby/filters as you wish. Now it is as simple as
Upvotes: 16
Reputation: 4336
It is possible to sort the results by a nested single-cardinality property, for example: http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$top=50&$expand=Customer&$orderby=Customer/City
AFAIK, it's not possible to do this with a navigation property that has a cardinality of many (though it would be useful in expand scenarios to order what comes back in the expanded feed).
Upvotes: 14