MongoDb c#驱动2.0 BsonNull用法
本文关键字:BsonNull 用法 驱动 MongoDb | 更新日期: 2023-09-27 18:06:44
我在Profile
类中有isDeleted
Nullable
属性。
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
如何实现空检查
如果IsDeleted
可为空,您可以在查询时使用简单的null
而不是BsonNull.Value
:
Builders<Profile>.Filter.Eq(p => p.IsDeleted, null)