How to do a case-insensitive OData filter

2 posts, 0 answers
  1. dcadler
    dcadler avatar
    9 posts
    Member since:
    Dec 2019

    Posted 20 Feb 2020 Link to this post

    I am using the DataSourceRequest.ToODataString() but the resulting request to my OData is case sensitive. I have seen examples of the $filter clause that uses the OData tolower method to give case-insensitive search.

     

    For example, the following calls to me ASP.NET Core 3.1 / Microsoft.AspNetCore.Odata v7.3.0 API all return the same result set; 

    https://myapi/v1/accounts?$filter=contains(tolower(AccountName),tolower('eng'))&$top=2&$skip=0&$count=true

    https://myapi/v1/accounts?$filter=contains(tolower(AccountName),tolower('Eng'))&$top=2&$skip=0&$count=true

    https://myapi/v1/accounts?$filter=contains(tolower(AccountName),tolower('eNg'))&$top=2&$skip=0&$count=true

    Is there a way to modify your DataSourceRequest.ToODataString to support this type of client site modification so I can use it to do case-insensitive filters?

     

     

     

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5937 posts

    Posted 21 Feb 2020 Link to this post

    Hello,

    Would either of these approaches work for your case right now:

    I am asking because at this point we don't have such a feature, but it looks like that heavily depends on the backend and database so using string operations might be the more flexible approach, and may let you use that right now as opposed to waiting for an implementation.

     

    Regards,
    Marin Bratanov
    Progress Telerik

     UI for Blazor
Back to Top