15

我正在尝试使用此 URL 在 OData 中进行一些自定义排序

localhost:82/odata.svc/ComponentPresentations?$filter=TemplateId eq 2894 and publicationId eq 10&$expand=Component/Keywords?$orderby=Title desc

where Componentis a property ofComponentPresentationKeywordsis property of Component,我想根据关键字的Title属性对 ComponentPresentation 进行排序。但是关键字和标题是组件表示的属性

有没有办法根据 Keword 的 title 属性对结果进行排序?哪个是Component的子代,哪个是ComponentPresentation的子代?

4

3 回答 3

16

只想提一下,从 OData V4 开始就有可能。您可以根据需要嵌套任意数量的扩展/选择/排序/过滤器。现在它很简单

http://services.odata.org/V4/Northwind/Northwind.svc/Orders?$select=OrderID&$expand=Order_Details($select=UnitPrice;$orderby=Quantity)

于 2015-05-27T09:09:36.863 回答
13

可以通过嵌套的单基数属性对结果进行排序,例如:http ://services.odata.org/V3/Northwind/Northwind.svc/Orders?$top=50&$expand=Customer&$orderby=Customer /城市

AFAIK,不可能使用具有许多基数的导航属性来执行此操作(尽管在扩展场景中对扩展提要中返回的内容进行排序很有用)。

于 2012-09-24T20:53:26.330 回答
1

在查询结束时使用 expandobject/field 附加顺序

localhost:82/odata.svc/ComponentPresentations?$filter=TemplateId eq 2894 和 publicationId eq 10&$expand=Component/Keywords?$orderby=Component/Title desc

于 2020-10-18T20:15:35.857 回答