Open mark--stephenson opened 7 years ago
Hello Mark, team, I believe that is expected behavior (at least for LINQ-to-objects) - Enumerable.All() returns true if collection is empty.
You may workaround this issue checking if addresses
is not empty by adding and addresses/any()
to your uri:
~/odata/v1/people?$filter=addresses/all(a: a/country eq 'UK') and addresses/any()
I am seeing some unusual behaviour in my oData web api project when filtering.
My domain has "people", who can have non, one, or many "addresses" associated with them. For example, see below for the result of http://localhost:4839/odata/v1/people?$expand=addresses
If I want to filter people and only return people who have all their addresses in the UK, I would expect the following query to work http://localhost:4839/odata/v1/people?$filter=addresses/all(a: a/country eq 'UK'), but this returns Bob Smith, Jane Bond and Glen Anthony. Can anyone explain why Glen Anthony is returned by this query, or is it a bug?
I'm using Microsoft.AspNet.OData v6.0.0