-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
String comparison fails when using const and compiled Models. #32617
Comments
This Issue does not happen on older EF-Core versions. |
Note for triage: Regression in the Unicodeness of the const string in the query is not being generated correctly when the compiled model is being used. With the compiled mode--see the non-Unicode string literal: SELECT CASE
WHEN EXISTS (
SELECT 1
FROM [Tests] AS [t]
WHERE [t].[Name] = 'RED') THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END Without the compiled model--the literal is Unicode: SELECT CASE
WHEN EXISTS (
SELECT 1
FROM [Tests] AS [t]
WHERE [t].[Name] = N'RED') THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END In EF7, we generate this with and without the compiled model: SELECT CASE
WHEN EXISTS (
SELECT 1
FROM [Tests] AS [t]
WHERE [t].[Name] = N'RED') THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END |
Still does not work in 8.0.1 |
@DxsSucuk the fixed was merged for 8.0.2, which should be out in a few weeks. |
File a bug
Description
When comparing an entity value with a const field value while also using compiled Models, EF Core creates a different SQL Statement and causes the query to fail. When you instead use a static field, it creates the correct SQL Statement and the query succeeds.
Include your code
Here is a simple snippet with comments explaining the Issue.
I will be including a zip files containing code that can be used to reproduce it.
EFCoreTest.zip
Include stack traces
No stacktrace.
Include verbose output
No related to the Package Manager or CLI.
Include provider and version information
EF Core version: 8.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.8.3
The text was updated successfully, but these errors were encountered: