With previous version of C# drivers (1.x) I could do :
var client = new MongoClient(settings);
var server = client.GetServer();
server.Shutdown();
How can I do this with driver version 2.2.3 ?
Update
Well the best I could find is something like this :
try
{
var client = new MongoClient(settings);
var adminDatabase = client.GetDatabase("admin");
var cmd = new BsonDocument("shutdown", 1);
adminDatabase.RunCommand<BsonDocument>(cmd);
}
catch (MongoConnectionException e)
{
if (!(e.InnerException is EndOfStreamException))
{
throw;
}
}
but I dont really like this, the Try/catch etc ...
They told me at the Google Groups Page that is because it should never be used from most applications.
Craig Wilson mentioned that shutdown is simply a command that can be send using
db.RunCommand("{shutdown: 1}")
So it isn't anymore available in the API .net Version 2.0.0 and above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With