private static void InnerExecuteQuery <T>(GenericRecordList <T> rl, IDbCommand command, string description, bool transformParameters) where T : ITypedRecord <T>
        {
            IDbCommand cmd = ADOAdaptersUtils.GetADOCommand(command);
            IDatabaseAccessProvider provider = DatabaseAccess.GetProviderForTransaction(cmd.Transaction);

            provider.ExecuteQuery(new ManagedCommand(provider.TransactionManager, cmd), rl, description, transformParameters, false);
        }
        public static int ExecuteNonQueryDontCleanParameters(IDbCommand command, string description, bool isApplication, bool skipLog)
        {
            IDbCommand cmd            = ADOAdaptersUtils.GetADOCommand(command);
            Command    wrapperCommand = new Command(GetExecutionForConnection(cmd.Connection), cmd);

            return(wrapperCommand.ExecuteNonQueryWithoutTransformParametersSyntax(description, isApplication, skipLog));
        }
        public static object ExecuteScalarDontCleanParameters(IDbCommand command, bool skipLog)
        {
            IDbCommand cmd            = ADOAdaptersUtils.GetADOCommand(command);
            Command    wrapperCommand = new Command(GetExecutionForConnection(cmd.Connection), cmd);

            return(wrapperCommand.ExecuteScalarWithoutTransformParametersSyntax(skipLog));
        }
        public static IDataReader ExecuteReader(IDbCommand command, string description, bool isApplication, bool transformParameters, bool skipLog)
        {
            try {
                // Save the values before execution because sometimes the drivers clears them from the IDbCommand when an exception occurs
                IDbCommand     cmd   = ADOAdaptersUtils.GetADOCommand(command);
                IDbConnection  conn  = cmd.Connection;
                IDbTransaction trans = cmd.Transaction;

                IDatabaseAccessProvider provider = null;
                bool hasProvider = trans != null && DatabaseAccess.TryGetProviderForTransaction(trans, out provider);

                IExecutionService   executionService = hasProvider ? provider.DatabaseServices.ExecutionService : GetExecutionForConnection(conn);
                ITransactionManager manager          = provider.TransactionManager;

                IDataReader reader = null;
                try {
                    if (transformParameters)
                    {
                        TransformParameters(cmd);
                    }
                    reader = executionService.ExecuteReader(cmd);
                    // NOTE: This reader will be closed automatically by the transaction manager at the end of the request
                    manager.AssociateReader(trans, reader);
                } catch (DbException e) {
                    executionService.OnExecuteException(e, cmd, reader, conn, trans, manager);
                    throw;
                }
                return(reader);
            } catch (InvalidDatabaseAccessException e) {
                throw new InvalidDBTransactionManagerAccess(e.Message);
            }
        }
        public static DataSet CreateAndFillDataSet(IDbCommand command, IDbDataAdapter adapter, string description, bool isApplication)
        {
            // Save the values before execution because sometimes the drivers clears them from the IDbCommand when an exception occurs
            IDbCommand     cmd   = ADOAdaptersUtils.GetADOCommand(command);
            IDbConnection  conn  = cmd.Connection;
            IDbTransaction trans = cmd.Transaction;

            IDatabaseAccessProvider provider = null;
            bool hasProvider = trans != null && DatabaseAccess.TryGetProviderForTransaction(trans, out provider);

            IExecutionService   executionService = hasProvider ? provider.DatabaseServices.ExecutionService : GetExecutionForConnection(conn);
            ITransactionManager manager          = provider.TransactionManager;

            try {
                DataSet dataSet;

                {
                    dataSet = new DataSet();
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet);
                }
                return(dataSet);
            } catch (DbException e) {
                executionService.OnExecuteException(e, cmd, null, conn, trans, manager);
                throw;
            }
        }
 public void CleanParameterSyntax(IDbCommand command)
 {
     try {
         IDbCommand cmd = ADOAdaptersUtils.GetADOCommand(command);
         DBHelper.TransformParameters(cmd);
     } catch (InvalidDatabaseAccessException e) {
         throw new InvalidDBTransactionManagerAccess(e.Message);
     }
 }
 public static int ExecuteNonQuery(IDbCommand command, bool skipLog)
 {
     try {
         IDbCommand cmd            = ADOAdaptersUtils.GetADOCommand(command);
         Command    wrappedCommand = new Command(GetExecutionForConnection(cmd.Connection), cmd);
         return(wrappedCommand.ExecuteNonQuery(skipLog));
     } catch (InvalidDatabaseAccessException e) {
         throw new InvalidDBTransactionManagerAccess(e.Message);
     }
 }
 public static object ExecuteScalar(IDbCommand command)
 {
     try {
         IDbCommand cmd            = ADOAdaptersUtils.GetADOCommand(command);
         Command    wrapperCommand = new Command(GetExecutionForConnection(cmd.Connection), cmd);
         return(wrapperCommand.ExecuteScalar());
     } catch (InvalidDatabaseAccessException e) {
         throw new InvalidDBTransactionManagerAccess(e.Message);
     }
 }
 public static IDataReader ExecuteStoredProcedure(IDbCommand command, DBKind dbKind, string readerVarName, bool skipLog)
 {
     try {
         IDbCommand cmd = ADOAdaptersUtils.GetADOCommand(command);
         TransformParameters(cmd);
         IDataReader reader = GetExecutionForKind(dbKind).ExecuteStoredProcedureWithResultSet(cmd, readerVarName);
         DatabaseAccess.GetProviderForTransaction(cmd.Transaction).TransactionManager.AssociateReader(cmd.Transaction, reader);
         return(reader);
     } catch (InvalidDatabaseAccessException e) {
         throw new InvalidDBTransactionManagerAccess(e.Message);
     }
 }
 public IDbDataParameter AddParameter(string connectionName, IDbCommand command, string name, DbType dbType, object paramValue)
 {
     try {
         IDbCommand        cmd = ADOAdaptersUtils.GetADOCommand(command);
         IDatabaseServices databaseServices = GetProviderFromConnectionNameOrMain(connectionName).DatabaseServices;
         Command           wrappedCommand   = new Command(databaseServices.ExecutionService, cmd);
         return(ADOAdaptersUtils.AdapterParameter(wrappedCommand.CreateParameter(name, dbType, paramValue).DriverParameter));
     } catch (ConnectionNotFoundException e) {
         throw new DBConnectionNotFoundException(e.Message);
     } catch (InvalidDatabaseAccessException e) {
         throw new InvalidDBTransactionManagerAccess(e.Message);
     } catch (InvalidTransactionReleaseException e) {
         throw new InvalidReleaseException(e.Message);
     }
 }
        public static IDbDataParameter AddParameterWithDirection(string connectionName, IDbCommand cmd, string name, DbType dbType, ParameterDirection direction)
        {
            try {
                IDatabaseServices databaseServices = String.IsNullOrEmpty(connectionName)?
                                                     DatabaseAccess.ForSystemDatabase.DatabaseServices:
                                                     DatabaseAccess.ForDBConnection(connectionName).DatabaseServices;
                Command command = new Command(databaseServices.ExecutionService, ADOAdaptersUtils.GetADOCommand(cmd));

                return(ADOAdaptersUtils.AdapterParameter(command.CreateParameterWithDirection(name, dbType, direction).DriverParameter));
            } catch (ConnectionNotFoundException e) {
                throw new DBConnectionNotFoundException(e.Message);
            } catch (InvalidDatabaseAccessException e) {
                throw new InvalidDBTransactionManagerAccess(e.Message);
            } catch (InvalidTransactionReleaseException e) {
                throw new InvalidReleaseException(e.Message);
            }
        }
        public static IDbDataParameter AddParameter(IDbCommand cmd, string name, DbType dbType, object paramValue, DBKind dbKind, bool magicReplace)
        {
            IExecutionService executionService = GetExecutionForKind(dbKind);

            if (magicReplace)
            {
                paramValue = executionService.TransformRuntimeToDatabaseValue(dbType, paramValue);
            }
            return(ADOAdaptersUtils.AdapterParameter(executionService.CreateParameter(ADOAdaptersUtils.GetADOCommand(cmd), name, dbType, paramValue)));
        }
        public static IDbDataParameter AddParameter(IDbCommand cmd, string name, DbType dbType, ObjectKey key, DBKind dbKind)
        {
            Command command = new Command(GetExecutionForKind(dbKind).DatabaseServices.ExecutionService, ADOAdaptersUtils.GetADOCommand(cmd));

            return(ADOAdaptersUtils.AdapterParameter(command.CreateParameter(name, dbType, key).DriverParameter));
        }