//3a. Lấy List Collection
public string ListCollections()
{
// 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 = "List Collections : <br/>";
//lấy database
var database = client.GetDatabase("HvDadabase");
//Lấy List Collection
var collectionList = database.ListCollections().ToList();
foreach (var row in collectionList)
{
re += row + "<br/>";
}
return re;
}
0 Nhận xét