Você pode usar
RunCommand
método para obter db.stats()
resultados assim:var command = new CommandDocument {{ "dbStats", 1}, {"scale", 1}};
var result = db.RunCommand<BsonDocument>(command);
Resultado será assim:
{
"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
}
E para
db.getCollectionNames()
; uma maneira é usar este comando: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"]);