2
votes

Is there a setting/configuration in .Net Core 2.2 where we can make oData queries to the backend like this and it would ignore the case? In the example below I would like all Cars with Brand FORD and Ford to appear in the search results

https://localhost/api/cars?$filter=contains(Brand,'FoRd')

I'm aware you can use toLower in the URL but I'm looking at a setting in the backend

1
You can check this article , but in my testing with Microsoft.AspNetCore.OData verion 7.2.2 , it works as case insensitive by default . Not sure what is the cause .Nan Yu
I just tried with version 7.2.2 and I get the same case sensitive behavior on the "filter contains" operationuser441365

1 Answers

3
votes

Thanks to Nan Yu's comment, I figured the reason for that example to work as case-insensitive is that instead of using an expression like:

contains(Name,'Dom')

they use:

contains(tolower(Name),'dom')

Do note that the field name (in this case Name) is prefixed with an OData's function call toLower() and the string 'Dom' has been manually lowered to 'dom'.