1

I have tables DEPatientVisit and DEPhysician

i need to filter the data based parameters

Sreekanth
  • 407
  • 4
  • 8
  • 20

2 Answers2

1

OData v4 introduces a new operator 'any', which may resolve your scenario. Your request url would looks like:

~/FalconCPDataService.svc/DEPhysicians?$format=json&$expand=DEPatientVisits&$filter=DEPatientVisits/any(v:v/StimulatorGourpId+eq+guid%27F321EDAB-14C6-4FF2-9485-00ABD176EBC4%27)

For more please reference this:http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html, section 5.1.1.5.1 any

Cory Klein
  • 51,188
  • 43
  • 183
  • 243
Tan Jinfu
  • 3,327
  • 1
  • 19
  • 20
  • It is a variable used to go though each DEPatientVisit in DEPhysicians.DEPatientVisits – Tan Jinfu Apr 27 '14 at 00:18
  • i ned to use v only there in place of v – Sreekanth Apr 27 '14 at 05:29
  • i used v but it showing response json array empty – Sreekanth Apr 28 '14 at 06:30
  • @mekala: I think tanjinfu's answer is correct. In order to query a subset of entity set by filtering property of elements of it's collection navigation property, you have to use "any" or "all". The reason is that by simply using "$filter=DEPatientVisits/StimulatorGourpId eq xxx" it is not clear if to return the DEPhysician as long as one of his DEPatientVisit has the required StimulatorGourpId or all its DEPatientVisit have the required StimulatorGroupId. So "any" or "all" is very necessary. The "v" in tanjinfu's URL is similar as the parameter in lambda expression of LINQ. – Yi Ding - MSFT May 06 '14 at 05:58
1

Thanks for inviting.

For the 1st query, your query target is entities in DEPhysicians? or DEPatientVisits? If want return entities in DEPhysicians, but inline expand navigation property DEPatientVisits, and want filter entities in DEPatientVisits with StimulatorGourpId. Try:

localhost:33396/FalconCPDataService.svc/DEPhysicians?$format=json&$expand=DEPatientVisits($filter=StimulatorGourpId eq guid'27F321EDAB-14C6-4FF2-9485-00ABD176EBC4')

For the 2nd query, Try:

localhost:33396/FalconCPDataService.svc/DEPhysicians?$format=json&$select=FullName&$expand=DEPatientVisits($select=Diagnosis,VisitDate;$filter=VisitID eq guid'F321EDAB-14C6-4FF2-9485-00ABD176EBC4')

All above query is following OData Protocol V4. $select and $filter can be inline $expand. But, I am not sure if it is implemented in odata4j. In sample service, the following are the similar query you can refer http://odatae2etest.azurewebsites.net/javatest/DefaultService/Orders?$expand=OrderDetails($select=OrderID;$filter=ProductID%20eq%206)

Maya
  • 816
  • 6
  • 5