Webapi: Support filtering string arrays

Created on 25 Sep 2019  路  2Comments  路  Source: OData/WebApi

What would it take to support filtering inside string arrays?

Suppose I had the class below, and wanted to filter on Contacts?$filter=any(PhoneNumbers, contains(item, '001')).

public class Contact
{
    public int Id { get; set; }

    public string[] PhoneNumbers { get; set; }
}

Most helpful comment

@bdebaere Can you try Contacts?$filter=PhoneNumbers/any(p: contains(p,'001') ? I am not sure if it would work but this would be the correct syntax in my opinion.

All 2 comments

@bdebaere Can you try Contacts?$filter=PhoneNumbers/any(p: contains(p,'001') ? I am not sure if it would work but this would be the correct syntax in my opinion.

@KanishManuja-MS Thanks, one more ) leads to a working solution: $filter=PhoneNumbers/any(p: contains(p,'001')).
I also tested $filter=PhoneNumbers/any(p: p eq '001') which returns the expected result.

Was this page helpful?
0 / 5 - 0 ratings