//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); }
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); }