The C# driver tutorial gives the following format for the connection string (which includes the option to specify a default database):
mongodb://[username:password@]hostname[:port][/[database][?options]]
But I don't see an overload of the GetDatabase method that doesn't require providing the database name. Is there some other method of getting a MongoDatabase instance that represents the database specified in the connection string?
There isn't an overload for that. You could use this approach instead:
var db = MongoDatabase.Create("mongodb://localhost:27017/SomeDatabase");
var collection = db.GetCollection("MyCollection");
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