Skip to content

Instantly share code, notes, and snippets.

@mizrael
Created December 29, 2015 10:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizrael/d9c9f061b3934a037b21 to your computer and use it in GitHub Desktop.
Save mizrael/d9c9f061b3934a037b21 to your computer and use it in GitHub Desktop.
simple Mongodb database factory implementation
public class MongoDatabaseFactory : IMongoDatabaseFactory
{
public IMongoDatabase Connect(string connectionString, string dbName)
{
if(string.IsNullOrWhiteSpace(connectionString))
throw new ArgumentNullException("connectionString");
if (string.IsNullOrWhiteSpace(dbName))
throw new ArgumentNullException("dbName");
var dbClient = new MongoClient(connectionString);
return dbClient.GetDatabase(dbName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment