以使用UseCSharpNullComparisonBehavi

以使用UseCSharpNullComparisonBehavi

本文介绍了我可以使用UseCSharpNullComparisonBehavior单个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我曾经是一个存储过程,其转变成EF查询的查询。现在已超时。使用SQL事件探查器,我可以看到生成的SQL唯一的区别是新的行为,其中EF轮流 entity.Property ==值到(实体。属性= @value OR(@value IS NULL和entity.Property IS NULL))。 我知道我可以将其关闭的通过设置整个背景 UseCSharpNullComparisonBehavior = FALSE ,但我真的只想做这一个查询。这可能吗? 或者,有没有写EF查询,因此它不会产生这样吗? 中的SQL的方式解决方案 您可以在上下文的 UseDatabaseNullSemantics 属性设置为真正。这在本质上是老 ObjectContext.UseCSharpNullComparisonBehavior 属性相反。 context.Configuration.UseDatabaseNullSemantics = TRUE; 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; 这篇关于我可以使用UseCSharpNullComparisonBehavior单个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-07 03:04