Beispiel #1
0
        protected void DoBeforeExecuteCommand(DbCommand command)
        {
            if (BeforeExecuteCommand != null)
            {
                var args = new CommandExecuteEventArgs(command);
                BeforeExecuteCommand(this, args);

                if (args.Cancel)
                {
                    throw new OperationCanceledException("Command Execution Canceled");
                }
            }
        }
Beispiel #2
0
        private int ExecuteNonQueryInternal(DbCommand command)
        {
            SetCommandTimeout(command);
            DbTransactionRegistry.SetCommandTransaction(command);

            if (BeforeExecuteCommand != null)
            {
                var args = new CommandExecuteEventArgs(command);
                BeforeExecuteCommand(this, args);

                if (args.Cancel)
                {
                    throw new OperationCanceledException("Command Execution Canceled");
                }
            }

            return(command.ExecuteNonQuery());
        }
Beispiel #3
0
        private DbDataReader ExecuteReaderInternal(DbCommand command, CommandBehavior behavior)
        {
            SetCommandTimeout(command);
            DbTransactionRegistry.SetCommandTransaction(command);

            if (BeforeExecuteCommand != null)
            {
                var args = new CommandExecuteEventArgs(command);
                BeforeExecuteCommand(this, args);

                if (args.Cancel)
                {
                    throw new OperationCanceledException("Command Execution Canceled");
                }
            }

            return(command.ExecuteReader(behavior));
        }