Check if Field Equals Null in MongoDb C# Driver 2.0
This actually works as expected with a little modification, which depends on:
BsonNull.Value
See this question for details: How to create Bson Document with Null value using C# official driver?
So the query is:
var fieldValueIsNullFilter = Builders<BsonDocument>.Filter.Eq("MyFieldName", BsonNull.Value);
Initially, I didn't realize BsonNull
has a Value
property.