Open cincuranet opened 1 week ago
Just to make this ticket easier to find for others facing the same issue, using UseSqlServer()
this results in query with WHERE 0 = 1
:
SELECT [h].[Id], [h].[Deleted]
FROM [Havit] AS [h]
WHERE 0 = 1
Because the manually constructed expression differs (it is missing the type) from what compiler produces for x => x.Deleted == null
- and because the "fix" is easy and straightforward - we don't consider this to be a high priority. That said, we'll put it into backlog and consider it for some future release, because especially for the Expression.Constant(null)
specifically it seems to be something nice to have.
The first query properly results in this SQL.
While the second results in this unexpected SQL.
The culprit seems to be that the expression
var equal = Expression.Equal(Expression.Property(parameter, "Deleted"), Expression.Constant(null));
does not contain the type information like thevar equal2 = Expression.Equal(Expression.Property(parameter, "Deleted"), Expression.Constant(null, typeof(DateTime?)));
which works fine.Include provider and version information
EF Core version: 8.0.10 and 9.0 RC2 Database provider: unrelated Target framework: .NET 8.0
cc @hakenr