【问题标题】:OData filter nested queryOData 过滤器嵌套查询
【发布时间】:2015-02-27 22:32:34
【问题描述】:

假设我们有一个可用的员工 json 结果集和指定的审阅者(作为嵌套的 json 结果集)。我想了解为员工分配了审阅者/未将审阅者分配给员工的情况。

通过使用下面的查询,我能够获得指定的审阅者。

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

这将返回审核者可用的所有员工。但是如何在审阅者不可用(或为空)的情况下返回结果?谢谢。

【问题讨论】:

    标签: odata


    【解决方案1】:

    如果您要获取原始过滤查询未返回的所有实体,您可以在已有的内容前面加上“不”:

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

    【讨论】:

    • 我知道“不”在那里,只是不知道把它放在哪里!。太好了,非常感谢。
    • 我试过这样http://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) 但它显示空 json 数组
    • DEPatientVisits 表响应为 {"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,"用户名":null ,"PainMapID":null,"VisitDate":"2014-02-19T10:18:42","VisitReason":"usLro4OooDlMNJuWZHqeSXEKFwphz3Y9dvUr37RxHFz0h86aCImdsxUjuMWX64RG"}
    • 可以解释问题出在哪里@Jen S
    • 类似上述 url {"odata.metadata":"192.168.1.105:33396/FalconCPDataService.svc/$metadata#DEPhysicians","value":[]} 的响应
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-14
      • 2013-01-28
      • 2022-08-02
      • 1970-01-01
      • 2018-05-10
      相关资源
      最近更新 更多