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