Esempio n. 1
0
        public MongoDBService(IMongoDBSetting settings)
        {
            var client = new MongoClient(settings.ConnectionString);

            MongoService = client.GetDatabase(settings.DatabaseName);
            CreateCollection(settings?.CollectionsNames);
        }
Esempio n. 2
0
 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()}");
     }
 }
Esempio n. 3
0
 public MusicRepository(IMongoDBSetting setting) : base(setting: setting, collectionName: "music")
 {
 }