Exemplo n.º 1
0
        private SynchronizedMongoRepository(MongoConfiguration conf)
        {
            MongoClientSettings settings = MongoClientSettings.FromConnectionString($"mongodb://{conf.Endpoint}:{conf.Port}");
            var client = new MongoClient(settings);

            client.Cluster.Initialize();
            List <string> tmp = client.ListDatabaseNames().ToList();

            foreach (string s in tmp)
            {
                Log.Info(s);
            }

            Database   = client.GetDatabase(conf.DatabaseName);
            Collection = Database.GetCollection <TObject>(typeof(TObject).Name);
            Log.Info($"Connected to {conf.Endpoint}:{conf.Port}");
        }