Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 LINQ to Entities 的 where 子句中检查多个条件?
如何检查该值是 false 还是 null
.Where(p => (p.Disabled == false || p.Disabled = null));
您可以使用常用的布尔运算符组合条件。
==条件的第二部分缺少您的解决方案:
==
.Where(p => (p.Disabled == false || p.Disabled == null)); // Here --------------------^
您可以进一步简化这一点,因为检查可空bool值是false或null等同于检查它不是true:
bool
false
null
true
.Where(p => p.Disabled != true);