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); } } }
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); } } }
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); } } }