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

后端 未结 5 1095
难免孤独
难免孤独 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:46

    You can use:

    var GoodItems = Query.Exists("FirstName");
    

    and than query

    People.Find(GoodItems);
    

    That way you'll get only the items that has "FirstName" defined.

提交回复
热议问题