Example #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="options">数据库连接字配置</param>
 private ConnectionPool(DBOptions options)
 {
     _logger                 = NLog.LogManager.GetCurrentClassLogger();
     _mySqlConnection        = options.ConnectionString;
     _initialConnections     = options.InitialConnections;
     _incrementalConnections = options.IncrementalConnections;
     _maxConnections         = options.MaxConnections;
 }
Example #2
0
 /// <summary>
 /// 创建一个连接池
 /// </summary>
 /// <param name="key"></param>
 /// <param name="option"></param>
 /// <returns></returns>
 public bool CreateConnectionPool(string key, DBOptions option)
 {
     if (!_poolList.ContainsKey(key))
     {
         _poolList.Add(key, ConnectionPool.CreateConnectionPoolInstance(option).CreatePool());
         return(true);
     }
     return(false);
 }
Example #3
0
 /// <summary>
 /// 通过配置实例化DBHelper
 /// </summary>
 /// <param name="dbOptions">配置项</param>
 public DBHelper(DBOptions dbOptions)
 {
     _dbOptions = dbOptions;
 }
Example #4
0
 public static ConnectionPool CreateConnectionPoolInstance(DBOptions options)
 {
     return(new ConnectionPool(options));
 }