-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Where" clause with "!string.Contains" produces incorrect SQL #30493
Comments
Note from triage: the change here will also likely change the use of the LIKE function directly. See #30262. |
Note: as per #30262, we'll be compensating for all uses of LikeExpression, not just specifically for Contains/StartsWith/etc. Also, while implementing, we can check the special-casing of StartsWith/EndsWith in preprocessing and see if we can remove them. Note that in my opinion, |
Poaching, this ended up being related to work on #11881 |
Closes dotnet#30493 Closes dotnet#11881 Closes dotnet#26735
Closes dotnet#30493 Closes dotnet#11881 Closes dotnet#26735
Closes dotnet#30493 Closes dotnet#11881 Closes dotnet#26735
Closes dotnet#30493 Closes dotnet#11881 Closes dotnet#26735
Closes dotnet#30493 Closes dotnet#11881 Closes dotnet#26735 (cherry picked from commit a07a1bd)
When querying an entity string column using the expression "!string.Contains('somestring)" the generated SQL does not account for (nor bring back) NULL string values.
Normally I would simply change my expression to a working version like "string.Contains('somestring') == false" (which does work correctly) but the expression is not within my control. Its wrapped up in a 3rd party tool that is applying "!string.contains('somevalue')" against the generic IQueryable interface.
Is there anyway I can work around this issue at present?
Reproduction steps:
Use the following table & data:
entity framework core model:
Expression 1, uses !string.Contains, (incorrect results)
generates the SQL
and results in
Expression 2, uses string.contans == false (correct results)
generates the SQL
and results in
Expression 3, uses string.contans != true (correct results)
generates the SQL
and results in
EF Core version: 7.0.3, Microsoft.EntityFrameworkCore.Design (7.0.3)
Database provider: Microsoft.EntityFrameworkCore.SqlServer (7.0.3)
Target framework: NET 6.0
IDE: Visual Studio 2022 17.4.3
Thanks so much in advance, Cheers.
The text was updated successfully, but these errors were encountered: