TrevorVonSeggern / Nodata

NOData is a OData like interface for restful C# API
MIT License
3 stars 0 forks source link

Filter: Allow filtering on children collections. #10

Open TrevorVonSeggern opened 6 years ago

TrevorVonSeggern commented 6 years ago

partner/id eq 1

TrevorVonSeggern commented 6 years ago

For the query: partner/favorite/id eq 1 Is there an implicit filter for: partner ne null and partner/favorite ne null?

What about collections? Do collections get filtered with all, any, or does it filter the items within the collection?

TrevorVonSeggern commented 6 years ago

According to Example 93 in the specification, filters that are applied to child collections only provide a filter on that collection, not the entire result set. Example: Categories:

[
{id: 1, labels: [ 'red', 'blue' ]},
{id: 2, labels: [ 'red', 'green' ]}
] 

=> to endpoint /api/Category The query /api/Category?$expand=labels($filter="red"), or the query /api/Category?$expand=labels & $filter="red" would return the result:

[
{id: 1, labels: [ 'red' ]},
{id: 2, labels: [ 'red' ]}
] 
TrevorVonSeggern commented 6 years ago

Unit test: [TestCase("children($filter=id eq 10)", 1, 2, 3, 4, 5, 6, 10)]