Esempio n. 1
0
        public IDataReader ExecuteReader(string cmdText, DbParam[] parameters, CommandType cmdType, CommandBehavior behavior)
        {
            this.CheckDisposed();

            List <OutputParameter> outputParameters;
            IDbCommand             cmd = this.PrepareCommand(cmdText, parameters, cmdType, out outputParameters);

            DbCommandInterceptionContext <IDataReader> dbCommandInterceptionContext = new DbCommandInterceptionContext <IDataReader>();

            IDbCommandInterceptor[] globalInterceptors = DbInterception.GetInterceptors();

            this.Activate();
            this.OnReaderExecuting(cmd, dbCommandInterceptionContext, globalInterceptors);

            IDataReader reader;

            try
            {
                reader = new InternalDataReader(this, cmd.ExecuteReader(behavior), cmd, outputParameters);
            }
            catch (Exception ex)
            {
                dbCommandInterceptionContext.Exception = ex;
                this.OnReaderExecuted(cmd, dbCommandInterceptionContext, globalInterceptors);

                throw WrapException(ex);
            }

            dbCommandInterceptionContext.Result = reader;
            this.OnReaderExecuted(cmd, dbCommandInterceptionContext, globalInterceptors);

            return(reader);
        }
        public IDataReader ExecuteReader(string cmdText, DbParam[] parameters, CommandType cmdType, CommandBehavior behavior)
        {
            this.CheckDisposed();

            IDbCommand cmd = this.PrepareCommand(cmdText, parameters, cmdType);

            this.Activate();

            IDataReader reader;

            try
            {
                reader = new InternalDataReader(this, cmd.ExecuteReader(behavior), cmd);
            }
            catch (Exception ex)
            {
                throw WrapException(ex);
            }

            return(reader);
        }