Du kan bruge RunCommand
metode til at få db.stats()
resultater som dette:
var command = new CommandDocument {{ "dbStats", 1}, {"scale", 1}};
var result = db.RunCommand<BsonDocument>(command);
Resultatet bliver således:
{
"db" : "Test",
"collections" : 7,
"objects" : 32,
"avgObjSize" : 94.0,
"dataSize" : 3008,
"storageSize" : 57344,
"numExtents" : 7,
"indexes" : 5,
"indexSize" : 40880,
"fileSize" : 67108864,
"nsSizeMB" : 16,
"dataFileVersion" : {
"major" : 4,
"minor" : 5
},
"extentFreeList" : {
"num" : 0,
"totalSize" : 0
},
"ok" : 1.0
}
Og for db.getCollectionNames()
; en måde er at bruge denne kommando:
var command = new CommandDocument { { "listCollections", 1 }, { "scale", 1 } };
var result = db.RunCommand<BsonDocument>(command);
// and to clear extra details
var colNames = result["cursor"]["firstBatch"].AsBsonArray.Values.Select(c => c["name"]);