I have a query that used to be a stored procedure and was converted to an EF query. It is timing out now. Using SQL Profiler, I can see the only difference in the SQL generated is the new behavior where EF turns entity.Property == value
into (entity.Property = @value OR (@value IS NULL AND entity.Property IS NULL))
.
I know I can turn this off for the entire context by setting UseCSharpNullComparisonBehavior = false
, but I really only want to do it for this one query. Is that possible?
Or, is there a way to write the EF query so it doesn't generate the SQL like this?
You can set the UseDatabaseNullSemantics
property of your context to true
. That is essentially the reverse of the old ObjectContext.UseCSharpNullComparisonBehavior
property.
context.Configuration.UseDatabaseNullSemantics = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With