如何根据OData中子级的某些属性对对象进行排序? [英] How can I order objects according to some attribute of the child in OData?

查看:183
本文介绍了如何根据OData中子级的某些属性对对象进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

其中ComponentComponentPresentation的属性,而KeywordsComponent的属性,我想根据关键字的Title属性对ComponentPresentation进行排序.但是关键字或标题都是Component Presentation的属性

Where Componentis 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

有没有一种方法可以根据Keword标题的属性对结果进行排序?哪个是Component的子代,哪个是ComponentPresentation的子代?

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?

推荐答案

只想提一下自OData V4起就有可能.您可以根据需要嵌套任意数量的扩展/选择/排序/过滤器.现在就这么简单

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

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

这篇关于如何根据OData中子级的某些属性对对象进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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