//2a. Lấy ListDatabases
public string ListDatabases()
{
// Replace the uri string with your MongoDB deployment's connection string.
var client = new MongoClient(
"mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false"
);
string re = "";
// Lấy ListDatabases
var dbList = client.ListDatabases().ToList();
re += "The list of databases on this server is: ";
//chạy vòng lặp lấy từng database
foreach (var row in dbList)
{
re += row;
}
return re;
}
0 Nhận xét