Search code examples
c#jsonmongodbmongodb-querymongodb-.net-driver

How to issue a find command using MongoDB C# Driver with native JSON criteria syntax?


Is there any way that I can issue a "find" command to a MongoDB collection thru the C# driver that uses the native json criteria syntax and not LINQ or QUeryBuilder syntax?


Solution

  • Yes there is:

    var json = "{'_id': 3456}";
    var doc= BsonDocument.Parse(json);
    var query = new QueryDocument(doc);
    var result = coll.Find(query);