So I have a BsonDocument b (let\'s say it has FirstName, LastName, Age), which you could access as b[\"FirstName\"], etc...
If I try to do b[\"asdfasdf\"] (which doesn\'
With the C# driver version 2, it might not be enough to check the existence of the field. The line:
var firstName = report.GetValue("FirstName", null);
will return a BsonNull object if FirstName is actually null in the db, when in fact you'd like to get a string. One way to take this into consideration in a one line code is:
BsonDocument document;
string firstName = ((Func)(d => { var v = d.GetValue("FirstName", null); return v.IsBsonNull ? null : v.AsString; }))(document);