2

Let's assume we have an employee json resultset and assigned reviewer (as nested json resultset) available. I would like to find out case where a reviewer is assigned/and reviewer not assigned to the employee.

By using the query below I was able to get assigned reviewer.

$filter=Reviewer/any(reviewer: reviewer/ReviewerId gt 0)

This returns all employees where reviewer is available. But how do I return result where reviewer is unavailable (or empty)? Thanks.

xtrip
  • 865
  • 1
  • 8
  • 10

2 Answers2

3

If you're looking to get all the entities that weren't returned by your original filter query, you could just put a "not" in front of what you have already:

$filter=not Reviewer/any(reviewer: reviewer/ReviewerId gt 0)
Jen S
  • 4,465
  • 1
  • 32
  • 28
  • I knew "not" was there, just didn't figure out where to put it!. Great, and many thanks. – xtrip Jul 24 '13 at 19:58
  • i tried like thishttp://192.168.1.105:33396/FalconCPDataService.svc/DEPhysicians?$format=json&$expand=DEPatientVisits&$filter=DEPatientVisits/any(value:value/StimulatorGroupID+eq+guid%2756F18F45-CD99-4D41-8128-F9BAD7A8892F%27) but it showing empty json array – Sreekanth Apr 29 '14 at 05:00
  • the DEPatientVisits table response is {"odata.metadata":"localhost:33396/FalconCPDataService.svc/$metadata#DEPatientVisits","value":[{"VisitID":"f321edab-14c6-4ff2-9485-00abd176ebc4","PatientID":"c588df3b-9ea4-439b-9ab6-968a793dad2b","StimulatorGroupID":"b08d89e2-7dba-48ce-9430-282501397550","PhysicianID":null,"UserName":null,"PainMapID":null,"VisitDate":"2014-02-19T10:18:42","VisitReason":"usLro4OooDlMNJuWZHqeSXEKFwphz3Y9dvUr37RxHFz0h86aCImdsxUjuMWX64RG"} – Sreekanth Apr 29 '14 at 05:02
  • can please explain where is problem @Jen S – Sreekanth Apr 29 '14 at 05:03
  • the response like for above url {"odata.metadata":"192.168.1.105:33396/FalconCPDataService.svc/$metadata#DEPhysicians","value":[]} – Sreekanth Apr 29 '14 at 05:24
  • @mekala, could you please make a separate StackOverflow question? It's really tough to share code in comments, and making it its own question will give it much wider visibility. – Jen S Apr 30 '14 at 01:43
  • these are the my questions http://stackoverflow.com/questions/23290813/odata-filter-query http://stackoverflow.com/questions/23362275/odata-url-conversion-with-descending-orderby/23377463?noredirect=1#23377463 – Sreekanth Apr 30 '14 at 04:41
  • @Jen S can you try to answer my questions. – Sreekanth May 01 '14 at 18:42
0

$filter=Reviewer/all(reviewer: reviewer/ReviewerId lt 0 or reviewer/ReviewerId eq 0) :)

Alexander Vasilyev
  • 1,273
  • 2
  • 15
  • 22