using MongoDB.Driver; using MongoDB.Bson; var dbClient = new MongoClient("mongodb://username:password@localhost:27017/admin?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false"); var dbList = dbClient.ListDatabases().ToList(); IMongoDatabase db = dbClient.GetDatabase("MyDB"); var DocName = db.GetCollection<BsonDocument>("DocName"); var filter = Builders<BsonDocument>.Filter.Eq("guid", "00bf02eb-e71b-4a30-a36b-ad87134b05dd"); var command = new BsonDocument { { "dbstats", 1 } }; var result = db.RunCommand<BsonDocument>(command); Console.WriteLine("The List of Databases are:"); foreach (var item in dbList) { Console.WriteLine(item); } Console.WriteLine(result.ToJson());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)