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

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