コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="databaseProvider"></param>
 /// <param name="dbConfig"></param>
 public MongoBaseRepository(IMongoDatabaseProvider databaseProvider, MonogoDbConfig dbConfig)
 {
     Ensure.NotNull(databaseProvider, "IMongoDatabaseProvider");
     Ensure.NotNull(dbConfig, "MonogoDbConfig");
     _databaseProvider = databaseProvider;
     DbConfig          = dbConfig;
 }
コード例 #2
0
        /// <summary>
        ///  获取 <see cref="IMongoDatabase"/>.
        /// </summary>
        /// <param name="config">MongoDb配置</param>
        /// <exception cref="System.ArgumentNullException">config</exception>
        /// <returns><see cref="IMongoDatabase"/></returns>
        public IMongoDatabase GetDatabase(MonogoDbConfig config)
        {
            Ensure.NotNull(config, "MonogoDbConfig");
            MongoUrl mongoUrl    = new MongoUrl(config.ConnectionString);
            var      mongoClient = new MongoClient(mongoUrl);

            return(mongoClient.GetDatabase(mongoUrl.DatabaseName ?? config.DatabaseName));
        }
コード例 #3
0
 public RpcMonitorRequestRepository() : base(new MongoDatabaseProvider(), MonogoDbConfig.GetConfig())
 {
 }