简体   繁体   English

Odata网址转换(降序排列)

[英]Odata Url conversion with descending orderby

i need to get data by descending orderby Visidate of patient so i tried url like this 我需要通过按患者的Visidate降序来获取数据,所以我尝试了这样的网址

192.168.1.105:33396/FalconCPDataService.svc/DEPhysicians?$format=json&$expand=DEPatientVisits&$orderby=DEPatientVisits/VisitDate+desc

but showing exception 但显示异常

{"odata.error":{"code":"","message":{"lang":"en-US","value":"The parent value for a property access of a property 'VisitDate' is not a single value. Property access can only be applied to a single value."}}} {“ odata.error”:{“ code”:“”,“ message”:{“ lang”:“ zh-CN”,“ value”:“属性“ VisitDate”的属性访问的父值不是单个值。属性访问只能应用于单个值。“}}}

The reason is that DEPatientVisits is not a single valued navigation property, so it is unable to append a property name to it. 原因是DEPatientVisits不是单值导航属性,因此无法向其添加属性名称。 If it is a single valued, it works fine, such as: 如果它是单个值,则可以正常工作,例如:

http://services.odata.org/v4/OData/OData.svc/Products?$expand=Supplier&$orderby=Supplier/Name

Thanks for inviting. 感谢您的邀请。

I am not fully understand your question. 我不完全理解你的问题。 you want to sort entities in DEPhysicians? 您想对DEPhysicians中的实体进行排序? or DEPatientVisits? 或DEPatientVisits?

If you are try to get DEPhysicians inline expand DEPatientVisits, and want sort entities in DEPatientVisits by VisitDate, you can try: 如果您试图让DEPhysicians内联展开DEPatientVisits,并希望通过VisitDate在DEPatientVisits中对实体进行排序,则可以尝试:

locolhost/FalconCPDataService.svc/DEPhysicians?$format=json&$expand=DEPatientVisits($orderby=VisitDate desc)

If you are try to sort entities in DEPhysicians according to DEPatientVisits\\VisitDate, then, just as the answer from @tanjinfu, DEPatientVisits should not be a collection. 如果您尝试根据DEPatientVisits \\ VisitDate对DEPhysicians中的实体进行排序,则就像@tanjinfu的回答一样,DEPatientVisits不应是集合。 Otherwise, which VisitDate of entry in DEPatientVisits you want to used to sort? 否则,您要用于排序的DEPatientVisits中的哪个VisitDate日期?

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

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