Odata Url conversion with descending orderby

浪子不回头ぞ 提交于 2019-12-13 12:31:50

问题


i need to get data by descending orderby Visidate of patient so i tried url like this

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."}}}


回答1:


The reason is that DEPatientVisits is not a single valued navigation property, so it is unable to append a property name to it. 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



回答2:


Thanks for inviting.

I am not fully understand your question. you want to sort entities in DEPhysicians? or DEPatientVisits?

If you are try to get DEPhysicians inline expand DEPatientVisits, and want sort entities in DEPatientVisits by VisitDate, you can try:

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. Otherwise, which VisitDate of entry in DEPatientVisits you want to used to sort?



来源:https://stackoverflow.com/questions/23362275/odata-url-conversion-with-descending-orderby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!