1

我在 ASP.NET MVC 4 中创建了一些东西,在我的一个表中有一个 type 字段datetime。在更新之前,该字段默认为空。我正在尝试从此表中选择具有此字段为空的行,但我的 LINQ 查询始终不返回任何内容。这是我的查询。

from m in this._db.MessageReadStates
where m.UserName == name
      && m.ReadDate == null
select m

我是 C# 新手,所以有没有正确的方法来检查 null?

4

1 回答 1

6

您要检查类型的HasValue属性Nullable<DateTime>

&& !m.ReadDate.HasValue
于 2012-04-30T18:29:48.657 回答