[英]Entity Framework converting the query to is null
When I run = null
in Management Studio, it returns no rows but when I run is null
I get data back.当我在 Management Studio 中运行
= null
时,它不返回任何行,但是当我运行is null
我会返回数据。 In Entity Framework, it is converting the query to is null, Is there any alternative so I can just do the = null
in Entity Framework?在实体框架中,它正在将查询转换为空,有没有其他选择,所以我可以在实体框架中执行
= null
?
This return no rows这不返回任何行
SELECT *
FROM cart c
WHERE OrderId = NULL
This return 1000 rows这返回 1000 行
SELECT *
FROM cart c
WHERE OrderId IS NULL
EF List count 1000 rows EF 列表计数 1000 行
var Pending = (from c in db.Cart
where sc.OrderId == null
select sc.CartId).ToList();
Null means unknown value. Null 表示未知值。 In SQL trying to equate any value to NULL will result in FALSE, which makes sense.
在 SQL 中,试图将任何值等同于 NULL 将导致 FALSE,这是有道理的。 As such, 2 = NULL is FALSE.
因此,2 = NULL 为 FALSE。 NULL = NULL is FALSE.
NULL = NULL 为假。 However, column IS NULL checks that the value of the column is NULL.
但是,列 IS NULL 检查列的值是否为 NULL。
The semantics of C# is different and eventually translates your query to IS NULL when the EF framework sends the query to the server. C# 的语义是不同的,当 EF 框架将查询发送到服务器时,最终会将您的查询转换为 IS NULL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.