C# equivalent to db.repairDatabase()

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

I am able to compact collections:

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

But I don't manage to call repairDatabase.

Answers


In response to your comment that you got an exception with the message "bad option", it turns out that the server is picky about whether you use 1 or true as the value for the repairDatabase field. The following two are equivalent and both fail because the server doesn't like "true" instead of "1":

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

but this works:

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

You could report a JIRA against the server if this concerns you:

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


The database.RunCommand method is overloaded. It can also take a string that is the name of command, as follows:

database.RunCommand("repairDatabase")

It also returns a CommandResult object.


Need Your Help

Magento with APC enabled - can not download product files

magento download apc php-fpm

I have a Magento (CE version 1.9) site run on NGINX + PHP_FPM. Everything worked well.

Load an image into a JPanel in an applet

java image swing paintcomponent jfilechooser

base on this thread :Java: Load image from file, edit and add to JPanel

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.