mclark1129
mclark1129

Reputation: 7592

OData OrderBy Syntax for Primitive Collection

When querying a collection of complex objects with OData, I would reference the property name of the field to sort and optionally a direction:

http://server/customers?$orderBy=Name desc

What's the syntax for ordering a collection of a primitive type, such as a collection of strings?

http://server/tags?$orderBy={WhatGoesHere} desc

Upvotes: 1

Views: 825

Answers (1)

jps
jps

Reputation: 22545

You can reference the primitive with $it, so your request should be

http://server/tags?$orderby=$it desc

as you can see here: https://issues.oasis-open.org/browse/ODATA-393 it was added in OData 4.0, if you use an older version it will probably not work

Upvotes: 2

Related Questions