示例#1
0
 public SqlServerAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log, DataType.SqlServer)
 {
     this._util = util;
     MasterPool = new SqlServerConnectionPool("主库", masterConnectionString, null, null);
     if (slaveConnectionStrings != null)
     {
         foreach (var slaveConnectionString in slaveConnectionStrings)
         {
             var slavePool = new SqlServerConnectionPool($"从库{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
             SlavePools.Add(slavePool);
         }
     }
 }
示例#2
0
 public SqlServerAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings) : base(DataType.SqlServer)
 {
     base._util = util;
     if (!string.IsNullOrEmpty(masterConnectionString))
     {
         MasterPool = new SqlServerConnectionPool("主库", masterConnectionString, null, null);
     }
     if (slaveConnectionStrings != null)
     {
         foreach (var slaveConnectionString in slaveConnectionStrings)
         {
             var slavePool = new SqlServerConnectionPool($"从库{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
             SlavePools.Add(slavePool);
         }
     }
 }
示例#3
0
 public SqlServerAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func <DbConnection> connectionFactory) : base(DataType.SqlServer, masterConnectionString, slaveConnectionStrings)
 {
     base._util = util;
     if (connectionFactory != null)
     {
         MasterPool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.SqlServer, connectionFactory);
         return;
     }
     if (!string.IsNullOrEmpty(masterConnectionString))
     {
         MasterPool = new SqlServerConnectionPool("主库", masterConnectionString, null, null);
     }
     if (slaveConnectionStrings != null)
     {
         foreach (var slaveConnectionString in slaveConnectionStrings)
         {
             var slavePool = new SqlServerConnectionPool($"从库{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
             SlavePools.Add(slavePool);
         }
     }
 }