C # is equivalent to db.repairDatabase ()

Is there a way to call the MongoDB function db.repairDatabase () from a C # driver?

I can compress collections:

database.RunCommand(new CommandDocument("compact","collectionname"));

But I am unable to call repairDatabase.

+3
source share
2 answers

In response to your comment that you received an exception from the “bad option” message, it turns out that the server is picky whether you use 1 or true value of the repairDatabase field. The following two equivalents and both fail because the server does not like "true" instead of "1":

database.RunCommand("repairDatabase");
database.RunCommnad(new CommandDocument("repairDatabase", true));

but it works:

database.RunCommnad(new CommandDocument("repairDatabase", 1));

You can tell JIRA about the server if this bothers you:

https://jira.mongodb.org/browse/SERVER

+1
source

database.RunCommand . , , :

database.RunCommand("repairDatabase")

CommandResult.

+1

All Articles