public override object AcquireConnection(object txn)
{
MongoDatabase database = null;
if (string.IsNullOrWhiteSpace(_connectionString))
UpdateConnectionString();
if (!string.IsNullOrWhiteSpace(_connectionString))
{
MongoServer mongoinstance = new MongoClient(_connectionString).GetServer();
if (string.IsNullOrWhiteSpace(DatabaseName))
throw new Exception("No database specified");
database = mongoinstance.GetDatabase(DatabaseName);
}
else
{
throw new Exception("Can not connect to MongoDB with empty connection string");
}
return database;
}