You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT CASE
WHEN EXISTS (
SELECT1FROM [user].[tbl_preferences] AS [t]
WHERE [t].[user_id] = @__userId AND CAST(JSON_VALUE([t].[data],'$.Email.Enabled') ASbit)) THEN CAST(1ASbit)
ELSE CAST(0ASbit)
END
Exception
Microsoft.Data.SqlClient.SqlException (0x80131904): An expression of non-boolean type specified in a context where a condition is expected, near ')'.
at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__208_0(Task`1 result)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__273_0(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
If we examine the query, it is incomplete and missing the equality compare for CAST(JSON_VALUE([t].[data],'$.Email.Enabled') AS bit)
It should have been CAST(JSON_VALUE([t].[data],'$.Email.Enabled') AS bit) = CAST(1 AS bit)
SELECT CASE
WHEN EXISTS (
SELECT1FROM [user].[tbl_preferences] AS [t]
WHERE [t].[user_id] = @__userId AND CAST(JSON_VALUE([t].[data],'$.Email.Enabled') ASbit) = CAST(1ASbit)) THEN CAST(1ASbit)
ELSE CAST(0ASbit)
END
Query fails when trying to filter on a Json column, where the property in the document is of type
boolean
Minimal code to reproduce the error:
Now when I want to find if a user has the email preference enabled
Below is the SQL statement generated
Exception
If we examine the query, it is incomplete and missing the equality compare for
CAST(JSON_VALUE([t].[data],'$.Email.Enabled') AS bit)
It should have been
CAST(JSON_VALUE([t].[data],'$.Email.Enabled') AS bit) = CAST(1 AS bit)
EF Core version: 7.0.3
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
The text was updated successfully, but these errors were encountered: