VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 51 forks source link

Caching expressions with "string.Equals()" does not work #33

Closed maximgorbatyuk closed 5 years ago

maximgorbatyuk commented 5 years ago

If we cache an expression that contains string.Equals(string), a result will be the same even any kind of string value would be passed as arguments. But a way string == string works.

VahidN commented 5 years ago

I added a test for it and I can't reproduce it. IsCacheHit is always false here, which means it doesn't read the value from the cache, when it's using different random values.

maximgorbatyuk commented 5 years ago

Sorry for late response, @VahidN . I have tried some ways to reproduce an it seems like the bug will appear when I use "Invariant" comparing. Look to the screenshots below: When I use `string.Equals("ololo", InvariantCultureIgnoreCase) the bug appears: reproduced bug

When I use string.ToUpperInvariant() == string.ToUpperInvariant() the bug appears: reproduced upper

When I use just string.Lower() == string.Lower() the bug does not appear: all is ok lower

Here is a piece of code to make yor way to reproduce the bug more easy: https://gist.github.com/maximgorbatyuk/4a48e227e7f47d3097860b58678059f0

VahidN commented 5 years ago
maximgorbatyuk commented 5 years ago

Oh, thank you for links to the materials. We use PostgresQL instead of MSSQL server. So, to make it clear, we should use just .Where(x => x.Title == title) to search with insensitive case in LinqToSql even title has some kind of "pOsT1"value, isn't it?

VahidN commented 5 years ago
maximgorbatyuk commented 5 years ago

Thank you for explanation of background!

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.