public MongoRepository(IMongoDbConfig config) { var client = new MongoClient(config.ConnectionString); var database = client.GetDatabase(config.DatabaseName); _collection = database.GetCollection <T>(config.CollectionName); }
public PessoaMongoRepository(IMongoDbConfig mongoDbConfig) { this._mongoDbConfig = mongoDbConfig; MongoClient mongoClient = new MongoClient(mongoDbConfig.CaminhoDaConexao); var bancoDeDados = mongoClient.GetDatabase(mongoDbConfig.NomeDoBanco); _pessoas = bancoDeDados.GetCollection <Pessoa>(_nomeColecao); }
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(); }
/// <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); }
public DbContext(IMongoDbConfig config) { var client = new MongoClient(config.ConnectionString); _db = client.GetDatabase(config.Database); }
public FileManagementMongoDbContext(IMongoDbConfig config) { var client = new MongoClient(config.ConnectionString); _database = client.GetDatabase(config.Database); }