我有一个查询的形式:
var fruits = (from p in fruitDB
where (p.Fruit.FruitID == fruitID && p.Color.ColorID != null )
select p.Color).Distinct();
VS 2010 给了我一条蓝色下划线并告诉我“Expression is always true”。现在我同意如果数据库中的数据没有被塞满,但就我而言,如果我不包含为 != null
那么这是一个错误还是基于我的数据库模式中设置的规则? (即使基础数据与之矛盾)
请您参考如下方法:
Color.ColorID 是什么类型?是整数吗?您应该检查 p.Color != null 吗?
