在OData中,有没有一种方法可以按数组中的第一个元素进行排序? [英] In OData, is there a way to order by the first element in an array?

查看:128
本文介绍了在OData中,有没有一种方法可以按数组中的第一个元素进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个OData 4端点,用于在表中显示数据.其中一列具有一组数据,这些数据是从我的元素内的字符串数组连接而成的.有没有一种方法可以按数组中的第一个元素排序?

I have an OData 4 endpoint I call for displaying data in a table. One of the columns has a set of data concatenated from a string array within my element. Is there a way to order by the first element in the array?

我的元素可能看起来像这样:

My element could look like this:

[ { "FirstName": "John", "MiddleNames": [ "Harry", "Bobby", "Sue" ], "LastName": "Jones" }, ... more elements ]

[ { "FirstName": "John", "MiddleNames": [ "Harry", "Bobby", "Sue" ], "LastName": "Jones" }, ... more elements ]

,我想按MiddleNames [0]订购.

and I would like to order by MiddleNames[0].

感谢您的帮助!

Thanks for the help! The documentation on $orderby is sparse at best...

推荐答案

OData v4不支持,该规范未提供针对集合或数组中特定项的语法,用于路径表达式,而$ orderby是路径表达式.但是,在所支持的条件下非常明确,因此通过设计忽略此限制.

This is NOT supported in OData v4, the specification does not provide syntax for targeting specific items within a collection, or an array, for path expressions and $orderby is a path expression. It is however very explicit on the conditions that are supported, by omission this restriction is therefore by design.

5.1.1.15 Path Expressions
Properties and navigation properties of the entity type of the set of resources that are addressed by the request URL can be used as operands or function parameters, as shown in the preceding examples.

可以通过与资源路径中相同的语法来使用复杂属性的属性,即通过指定复杂属性的名称,后跟正斜杠(/)和复杂属性的属性名称,等等.上,

Properties of complex properties can be used via the same syntax as in resource paths, i.e. by specifying the name of a complex property, followed by a forward slash (/) and the name of a property of the complex property, and so on,

与目标基数0..1或1相关的实体的属性和导航属性可通过指定导航属性,后跟正斜杠(/)和相关实体的属性名称来使用上.

Properties and navigation properties of entities related with a target cardinality 0..1 or 1 can be used by specifying the navigation property, followed by a forward slash (/) and the name of a property of the related entity, and so on.

如果复杂属性为null,或者没有实体关联(在目标基数为0..1的情况下),则其值及其组成部分的值将被视为null.

If a complex property is null, or no entity is related (in case of target cardinality 0..1), its value, and the values of its components, are treated as null.

这篇关于在OData中,有没有一种方法可以按数组中的第一个元素进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆