public static MongoDbConfig GetMongoDbConfig(string configJsonFile) { String jsonStr = File.ReadAllText(configJsonFile); MongoDbConfig config = JsonConvert.DeserializeObject <MongoDbConfig>(jsonStr); return(config); }
public MongoDatabaseContext(MongoDbConfig config) { this.config = config; (string username, string password) = GetAuth(config.AuthenticationFile); string mongoDbConnection = string.Format(config.Uri, $"{username}:{password}@", config.DatabaseName); Console.WriteLine("linking to mongodb by: " + mongoDbConnection); this.client = new MongoClient(); this.database = client.GetDatabase(config.DatabaseName); }
public MediaRecordMongoDatabaseContext(MongoDbConfig config) : base(config) { this.Image = this.database.GetCollection <Image>("Image"); }