public MongoDBService(IMongoDBSetting settings) { var client = new MongoClient(settings.ConnectionString); MongoService = client.GetDatabase(settings.DatabaseName); CreateCollection(settings?.CollectionsNames); }
public MongoRepository(IMongoDBSetting setting, string collectionName) { try { IMongoDatabase database = new MongoClient(setting.ConnectionString).GetDatabase(setting.DatabaseName); this._collection = database.GetCollection <TDocument>(collectionName); } catch (Exception ex) { Console.WriteLine($"Unable to connect to Mongo {ex.ToString()}"); } }
public MusicRepository(IMongoDBSetting setting) : base(setting: setting, collectionName: "music") { }