public ToasterService(IToastersDatabaseSettings settings) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); _toasters = database.GetCollection <Toaster>(settings.ToastersCollectionName); }
// IMongoCollection interface represents a typed collection: toasters public ToasterService(IToastersDatabaseSettings settings) { var client = new MongoClient(settings.ConnectionString); // the client provides the server instance to the local DB so that it can // perform actions on it var database = client.GetDatabase(settings.DatabaseName); // the database variable represents the client's connection to db _toasters = database.GetCollection <Toaster>(settings.ToastersCollectionName); // this connects to the actual collection, toasters }