MongoDB C# - Getting BsonDocument for an Element that doesn't exist

后端 未结 5 1090
难免孤独
难免孤独 2021-02-09 07:53

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\'

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-09 08:24

    Try the Contains method:

    var b = new BsonDocument();
    var exists = b.Contains("asdfasdf");
    

提交回复
热议问题