Beispiel #1
0
        /// <summary>
        ///  此函数只能在从库数据库连接中进行
        /// </summary>
        /// <param name="action"></param>
        public static void ExecuteDataReaderSlave(Action <DbDataReader> action, CommandType commandType, string commandText, Action <DbCommand> onExecuted = null, params DbParameter[] commandParameters)
        {
            void Transfer(Exception ex)
            {
                if (InstanceSlave != null && InstanceSlave.Pool.ConnectionList.Count > 0)
                {
                    InstanceSlave.ExecuteDataReader(action, commandType, commandText, onExecuted, commandParameters);
                }
                else
                {
                    InstanceMaster.ExecuteDataReader(action, commandType, commandText, onExecuted, commandParameters);
                }
            }

            try
            {
                Transfer(null);
            }
            catch (System.TimeoutException te)
            {
                WriteLog(te);
                Transfer(te);
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                WriteLog(ex);
                Transfer(ex);
            }
        }
Beispiel #2
0
 /// <summary>
 ///  此函数只能在读写数据库连接中进行
 /// </summary>
 /// <param name="action"></param>
 public static void ExecuteDataReader(Action <DbDataReader> action, CommandType commandType, string commandText, Action <DbCommand> onExecuted = null, params DbParameter[] commandParameters)
 {
     InstanceMaster.ExecuteDataReader(action, commandType, commandText, onExecuted, commandParameters);
 }
Beispiel #3
0
 /// <summary>
 ///  此函数只能在读写数据库连接中进行
 /// </summary>
 /// <param name="action"></param>
 public static void ExecuteDataReader(Action <NpgsqlDataReader> action, CommandType commandType, string commandText, params NpgsqlParameter[] commandParameters)
 {
     InstanceMaster.ExecuteDataReader(action, commandType, commandText, commandParameters);
 }