OData WebAPI, in-memory queryable and case-sensitivity

1.1k views Asked by At

I have a problem with OData WebAPI and querying a EnumerableQuery (a list on which I called .AsQueryable(). I have a entity set, a controller with a Get method which returns the IQueryable. When I query that entity set and use this $filter

$filter=SomeStringProp eq 'SomeValue'

I get only entities whose SomeStringProp equals 'SomeValue' by letters and casing. I would like to somehow force OData to use a case-insensitive comparer for all strings - even with function calls like this

$filter=contains(SomeStringProp, 'apple')

I would need OData to return entities whose SomeStringProp is equal to 'APPLE', 'PineApple' and 'AppleSauce'

Some additional information:

  • A database has nothing to do with this; as stated, the collection is in-memory
  • Using tolower() in OData queries is just a workaround, so it's not a solution to the problem
1

There are 1 answers

0
Fabian On

What you ask is not supported by Odata.

  • The recommended way for case case-insensitivity is using tolower (or toupper).

  • The contains keyword is already part of odata v4 and implemented in Web API.

Combine them both and your are done :)

Edit: Works just fine with the sample WS.