Question

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

Was it helpful?

Solution

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

OTHER TIPS

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top