OData query $filter conditions and case-sensitivity

后端 未结 4 525
花落未央
花落未央 2020-12-05 13:51

Does OData specify whether filter conditions on string fields are to be evaluated case-sensitively or case-insensitively?

Example: (from the docs)

/S         


        
相关标签:
4条回答
  • 2020-12-05 14:34

    It doesn't depend on database. Even if you perform query against database in case in-sensitive way then OData will do his own additional filtering and filter your data out.

    0 讨论(0)
  • 2020-12-05 14:38

    It is now possible to do case insensitive compare by setting EnableCaseInsensitive = true on the ODataUriResolver. I used this with Microsoft.AspNetCore.OData 7.1.0.

         var oDataUriParser = new ODataUriParser(model, uri)
         {
            Resolver = new ODataUriResolver { EnableCaseInsensitive = true}
         };
    

    Source: https://github.com/OData/WebApi/issues/812

    0 讨论(0)
  • 2020-12-05 14:49

    I would expect this is depended on your database collation setting, as the odata service is just performing a query. If Vitek's answer is correct, then odata is doing some post query filtering on the result set, and that should be strange, right?

    0 讨论(0)
  • 2020-12-05 14:56

    The "eq" operator is supposed to be case sensitive. Usage of tolower (or toupper) is the currently recommended way of doing this.

    0 讨论(0)
提交回复
热议问题