Exemplo n.º 1
0
 public CustomAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func <DbConnection> connectionFactory) : base(DataType.Custom, masterConnectionString, slaveConnectionStrings)
 {
     base._util = util;
     if (connectionFactory != null)
     {
         var pool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.SqlServer, connectionFactory);
         MasterPool = pool;
         _CreateCommandConnection = pool.TestConnection;
         _CreateParameterCommand  = CreateCommand();
         return;
     }
     throw new Exception(CoreStrings.S_CustomAdapter_OnlySuppport_UseConnectionFactory);
 }
Exemplo n.º 2
0
 public OdbcOracleAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func<DbConnection> connectionFactory) : base(DataType.OdbcOracle)
 {
     base._util = util;
     if (connectionFactory != null)
     {
         MasterPool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.OdbcOracle, connectionFactory);
         return;
     }
     if (!string.IsNullOrEmpty(masterConnectionString))
         MasterPool = new OdbcOracleConnectionPool("主库", masterConnectionString, null, null);
     if (slaveConnectionStrings != null)
     {
         foreach (var slaveConnectionString in slaveConnectionStrings)
         {
             var slavePool = new OdbcOracleConnectionPool($"从库{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
             SlavePools.Add(slavePool);
         }
     }
 }
Exemplo n.º 3
0
 public PostgreSQLAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func <DbConnection> connectionFactory) : base(DataType.PostgreSQL, masterConnectionString, slaveConnectionStrings)
 {
     base._util = util;
     if (connectionFactory != null)
     {
         MasterPool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.PostgreSQL, connectionFactory);
         return;
     }
     if (!string.IsNullOrEmpty(masterConnectionString))
     {
         MasterPool = new PostgreSQLConnectionPool(CoreStrings.S_MasterDatabase, masterConnectionString, null, null);
     }
     if (slaveConnectionStrings != null)
     {
         foreach (var slaveConnectionString in slaveConnectionStrings)
         {
             var slavePool = new PostgreSQLConnectionPool($"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
             SlavePools.Add(slavePool);
         }
     }
 }