示例#1
0
        //Initialize service with settings settings specified in appsettings.json
        public PostService(IBlogDatabaseSettings settings)
        {
            var client   = new MongoClient(settings.ConnectionString);
            var database = client.GetDatabase(settings.DatabaseName);

            _posts = database.GetCollection <Post>(settings.PostsCollectionName);
        }
示例#2
0
        public TagmapRepository(IBlogDatabaseSettings settings)
        {
            var client = new MongoClient(settings.ConnectionString);

            var database = client.GetDatabase(settings.DatabaseName);

            _tagmap = database.GetCollection <Models.Tagmap>(settings.TagMapCollectionName);
        }
        public BlogMongoDbContext(IBlogDatabaseSettings settings)
        {
            var            client  = new MongoClient(settings.ConnectionString);
            IMongoDatabase mongoDb = client.GetDatabase(settings.DatabaseName);

            Users    = mongoDb.GetCollection <ApplicationUser>(settings.UserCollectionName);
            Articles = mongoDb.GetCollection <Article>(settings.ArticleCollectionName);
            Comments = mongoDb.GetCollection <Comment>(settings.CommentsCollectionName);
        }