Esempio n. 1
0
        public MongoRepository(IMongoDbConfig config)
        {
            var client   = new MongoClient(config.ConnectionString);
            var database = client.GetDatabase(config.DatabaseName);

            _collection = database.GetCollection <T>(config.CollectionName);
        }
Esempio n. 2
0
        public PessoaMongoRepository(IMongoDbConfig mongoDbConfig)
        {
            this._mongoDbConfig = mongoDbConfig;

            MongoClient mongoClient  = new MongoClient(mongoDbConfig.CaminhoDaConexao);
            var         bancoDeDados = mongoClient.GetDatabase(mongoDbConfig.NomeDoBanco);

            _pessoas = bancoDeDados.GetCollection <Pessoa>(_nomeColecao);
        }
Esempio n. 3
0
        public CatalogContext(IMongoDbConfig config)
        {
            var client   = new MongoClient(config.ConnectionString);
            var database = client.GetDatabase(config.DatabaseName);

            Products = database.GetCollection <Product>(config.CollectionName);

            CatalogContextSeed.SeedData(Products).Wait();
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoDbContext"/> class.
        /// </summary>
        /// <param name="mongoDbConfig">The mongo database configuration.</param>
        public MongoDbContext(
            IMongoDbConfig mongoDbConfig
            )
        {
            MongoClientSettings settings = MongoClientSettings.FromUrl(
                new MongoUrl(mongoDbConfig.ConnectionString)
                );

            settings.SslSettings =
                new SslSettings()
            {
                EnabledSslProtocols = SslProtocols.Tls12
            };

            _client   = new MongoClient(settings);
            _database = _client.GetDatabase(mongoDbConfig.DatabaseName);
        }
Esempio n. 5
0
        public DbContext(IMongoDbConfig config)
        {
            var client = new MongoClient(config.ConnectionString);

            _db = client.GetDatabase(config.Database);
        }
Esempio n. 6
0
        public FileManagementMongoDbContext(IMongoDbConfig config)
        {
            var client = new MongoClient(config.ConnectionString);

            _database = client.GetDatabase(config.Database);
        }