Exemplo n.º 1
0
        public BookRepository(IMongoDbConfiguration mongoDbConfiguration)
        {
            MongoClient    mongoClient   = new MongoClient(mongoDbConfiguration.Server);
            IMongoDatabase mongoDatabase = mongoClient.GetDatabase(mongoDbConfiguration.Database);

            _books = mongoDatabase.GetCollection <Book>(_collectionName);
        }
Exemplo n.º 2
0
        public PostRepository(IMongoDbConfiguration settings)
        {
            var client   = new MongoClient(settings.ConnectionString);
            var database = client.GetDatabase(settings.DatabaseName);

            _posts = database.GetCollection <Post>(settings.PostCollectionName);
        }
 public MongoDatabaseProvider(
     IMongoDbConfiguration configuration)
 {
     Database = new MongoClient(configuration.ConnectionString)
                .GetServer()
                .GetDatabase(configuration.DatabaseName);
 }
Exemplo n.º 4
0
        public MongoRepository(IMongoDbConfiguration settings)
        {
            var client   = new MongoClient(settings.ConnectionString);
            var database = client.GetDatabase(settings.DatabaseName);

            _leftData  = database.GetCollection <MongoDiffData>(settings.LeftDataCollection);
            _rightData = database.GetCollection <MongoDiffData>(settings.RightDataCollection);
        }
Exemplo n.º 5
0
        // * IMongoDbConfiguration instance is retrieved from DI via constructor injection
        // * This allows access to mongoDbConfiguration.json MongoDb configuration values
        //      1) TweetsCollectionName 2) ConnectionString 3) DatabaseName
        public MongoDbServicer(IMongoDbConfiguration config)
        {
            // * Reads the server instance for performing database operations
            // * The constructor of this class is provided the MongoDB connection string
            var client = new MongoClient(config.ConnectionString);

            // * Represents the Mongo database for performing operations
            var database = client.GetDatabase(config.DatabaseName);

            // * Uses generic GetCollection<TDocument>(collection) method on the interface
            // * Enables access to data in a specific collection
            // * Perform CRUD operations against the collection after this method is called
            // * In the GetCollection<TDocument>(collection) method call:
            //      1) collection represents the collection name
            //      2) TDocument represents the CLR object type stored in the collection
            _twitterStatus = database.GetCollection <TwitterStatus>(config.TweetsCollectionName);
        }
 public DefaultMongoDbContextTest()
 {
     _configuration      = new MongoDbConfiguration();
     _mongoClientFactory = new MongoClientFactory();
     _mongoDbContext     = new DefaultMongoDbContext(_configuration, _mongoClientFactory);
 }
Exemplo n.º 7
0
 public MongoClientFactoryTest()
 {
     _configuration      = new MongoDbConfiguration();
     _mongoClientFactory = new MongoClientFactory();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Create a new instance of <see cref="DefaultMongoDbContext"/>.
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="mongoClientFactory"></param>
 public DefaultMongoDbContext(IMongoDbConfiguration configuration, IMongoClientFactory mongoClientFactory)
 {
     _mongoDbConfiguration = configuration;
     RegisterConventions();
     MongoClient = mongoClientFactory.CreateClient(configuration.ConnectionString);
 }
 public MongoDatabaseAccessService(IMongoDbConfiguration mongoDbConfiguration, IMapper mapper)
 {
     _mongoDbConfiguration = mongoDbConfiguration;
     _mapper = mapper;
     ConfigureService();
 }
Exemplo n.º 10
0
 public MongoDbProvider(IMongoDbConfiguration configuration)
 {
     _configuration = configuration;
 }
Exemplo n.º 11
0
 public MongoDbFactory(IMongoDbConfiguration mongoDbConfiguration)
 {
     _mongoDbConfiguration = mongoDbConfiguration;
 }
Exemplo n.º 12
0
 public MongoDatabaseProvider(IMongoDbConfiguration config)
 {
     _config = config;
     _client = new MongoClient(config.ConnectionString);
 }
Exemplo n.º 13
0
 public MongoDbFactory(IMongoDbConfiguration configuration)
 {
     Configuration = configuration;
 }