c# - 为什么在 linq 中应用 != 时不返回空值

标签 c# asp.net linq entity-framework

我用这个代码

var items2 = from item in context.Images
             where item.Reported != true
             select item;

但为什么“报告”列中不返回空值?

最佳答案

truefalsenull 的值不同。如果您需要返回两者,那么您需要将查询更改为:

var items2 = from item in context.Images
             where item.Reported != true || item.Reported == null
             select item;

关于c# - 为什么在 linq 中应用 != 时不返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16572570/

相关文章:

c# - 我应该如何将 .doc 文档保存到 SQL Server 数据库

javascript - 如何在一台电脑上绘制图像并传播它们?

使用 IQueryable、foreach 和多个Where 时的 LINQ to SQL 错误(或非常奇怪的功能)

c# - 列表包含 linq 中的 ID

c# - 为什么在 c# 和 vb.net 上运行时,该 linq 查询的 sql 查询不同?

c# - 使用 Selenium Webdriver 时,使用 InternetExplorerDriver - "Unexpected error launching Internet Explorer...."时出现以下错误

javascript - 按下一个按钮进行打印后,将焦点放在另一个按钮上

c# - 字节数组到文件

c# - 按值更改字典键

c# - 使用 C#,将包含二进制数据的字符串转换为字节数组的最有效方法是什么