MongoDb C # driver 2.0 Using BsonNull
I have a property isDeleted
Nullable
in a class Profile
.
Builders<Profile>.Filter.Eq(p => p.IsDeleted, BsonNull.Value)
But the following code caused the following compilation error:
Error 11 Cannot convert lambda expression to type
'MongoDB.Driver.FieldDefinition<MongoDB.DataTypes.Profile,MongoDB.Bson.BsonNull>'
because it is not a delegate type
How do I implement null validation?
+3
Vladislav Furdak
source
to share
1 answer
If IsDeleted
null, you can simply use simple null
instead BsonNull.Value
when querying:
Builders<Profile>.Filter.Eq(p => p.IsDeleted, null)
+3
i3arnon
source
to share