简体   繁体   English

OData OrderBy语法为原始集合

[英]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: 当使用OData查询复杂对象的集合时,我将引用要排序的字段的属性名称以及方向(可选):

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

You can reference the primitive with $it, so your request should be 您可以使用$ it引用该原语,因此您的请求应为

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 如您在此处看到的那样: https : //issues.oasis-open.org/browse/ODATA-393它是在OData 4.0中添加的,如果您使用的是旧版本,则可能无法正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM