问题
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.
回答1:
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)
回答2:
$filter=Reviewer/all(reviewer: reviewer/ReviewerId lt 0 or reviewer/ReviewerId eq 0) :)
来源:https://stackoverflow.com/questions/17840958/odata-filter-nested-query