Created
November 16, 2018 07:31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoConnector | |
{ | |
private readonly IMongoClient _client; | |
private readonly IMongoDatabase _database; | |
public MongoConnector(MongoConfig config) | |
{ | |
_client = new MongoClient(config.ConnectionString); | |
_database = _client.GetDatabase(config.DatabaseName); | |
} | |
public IMongoCollection<T> GetCollection<T>(string collectionName) | |
{ | |
return _database.GetCollection<T>(collectionName); | |
} | |
} | |
public interface MongoConfig | |
{ | |
string ConnectionString { get; set; } | |
string DatabaseName { get; set; } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment