public MongoFileManager(MongoConfiguration configuration) { _configuration = configuration; MongoClient client; if (!string.IsNullOrEmpty(configuration.Username) && !string.IsNullOrEmpty(configuration.Password)) { var credentials = MongoCredential.CreateCredential(configuration.Database, configuration.Username, configuration.Password); var settings = new MongoClientSettings() { Credential = credentials, Server = MongoServerAddress.Parse(configuration.Server.Replace("mongodb://", "")) }; client = new MongoClient(settings); } else { client = new MongoClient(configuration.Server); } var db = client.GetDatabase(configuration.Database); Bucket = new GridFSBucket(db); }
public MongoGenericRepository(MongoConfiguration configuration) { Collection = configuration.GetDatabase().GetCollection <T>(typeof(T).Name.Replace("Mongo", "")); }