Example #1
0
        public static MongoDbConfig GetMongoDbConfig(string configJsonFile)
        {
            String        jsonStr = File.ReadAllText(configJsonFile);
            MongoDbConfig config  = JsonConvert.DeserializeObject <MongoDbConfig>(jsonStr);

            return(config);
        }
Example #2
0
        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);
        }
Example #3
0
 public MediaRecordMongoDatabaseContext(MongoDbConfig config) : base(config)
 {
     this.Image = this.database.GetCollection <Image>("Image");
 }