Where is MongoServer.RunAdminCommand()

59 views
Skip to first unread message

John Woakes

unread,
Jul 3, 2012, 3:55:16 PM7/3/12
to mongodb...@googlegroups.com
I just upgraded the driver to 1.5 from 1.3.1 and now fixing compile errors.

The method RunAdminCommand() on the MongoServer class is gone. We were using this to run "replSetGetStatus" and various other commands.

What is the correct way to do this with the 1.5 driver. [we are not using auth].

John.

Robert Stam

unread,
Jul 3, 2012, 4:01:23 PM7/3/12
to mongodb...@googlegroups.com
The way to do this with the latest version of the C# driver is:

var adminDatabase = server.GetDatabase("admin");

and then either:

var resut = adminDatabase.RunCommand("commandName");

or

var command = new CommandDocument { ... };
var result = adminDatabase.RunCommand(command);

Sorry for the inconvenience, but as mentioned in the release notes this change was made because continuing to support the admin specific helper methods when authentication was involved would have required a large number of new overloads.

John Woakes

unread,
Jul 3, 2012, 4:07:12 PM7/3/12
to mongodb...@googlegroups.com
OK, I didn't see that in the release notes. I did see reference to removing properties and methods for admin. Did you consider providing a GetAdminDatabase() method to avoid the "admin" string?

I didn't know there was an "admin" database so learnt something new.

Thanks.

John.
Reply all
Reply to author
Forward
0 new messages