4

I have isDeleted Nullable property in Profile class.

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

But the following code raised next 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 to implement a null-check ?

i3arnon
  • 113,022
  • 33
  • 324
  • 344
Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46

1 Answers1

6

If IsDeleted is nullable, you can just use a simple null instead of BsonNull.Value when you query:

Builders<Profile>.Filter.Eq(p => p.IsDeleted, null)
i3arnon
  • 113,022
  • 33
  • 324
  • 344