2

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

Sreekanth
  • 407
  • 4
  • 8
  • 20

3 Answers3

3

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
Cory Klein
  • 51,188
  • 43
  • 183
  • 243
Tan Jinfu
  • 3,327
  • 1
  • 19
  • 20
1

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?

Maya
  • 816
  • 6
  • 5
  • thanks @Maya i tried url which one you gave to me but it showing {"odata.error":{"code":"","message":{"lang":"en-US","value":"Term 'DEPatientVisits($orderby=VisitDate desc)' is not valid in a $select or $expand expression."}}} – Sreekanth May 05 '14 at 05:05
0

I did this in the call to the odata. g?$orderby=Date_and_Time%20desc

which gave me my records in descending order from the table.

user1804469
  • 116
  • 2
  • 4