4

我在课堂上isDeleted Nullable有财产。Profile

Builders<Profile>.Filter.Eq(p => p.IsDeleted, BsonNull.Value)

但是以下代码引发了下一个编译错误:

Error 11    Cannot convert lambda expression to type 
'MongoDB.Driver.FieldDefinition<MongoDB.DataTypes.Profile,MongoDB.Bson.BsonNull>' 
because it is not a delegate type   

如何实施空检查?

4

1 回答 1

6

如果IsDeleted可以为空,则可以在查询时使用简单null的而不是BsonNull.Value

Builders<Profile>.Filter.Eq(p => p.IsDeleted, null)
于 2015-08-07T09:54:10.977 回答