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);
        }
Esempio n. 2
0
        public IDataReader ExecuteReader(string cmdText, DbParam[] parameters, CommandType cmdType, CommandBehavior behavior)
        {
            this.CheckDisposed();

#if DEBUG
            System.Diagnostics.Debug.WriteLine(AppendDbCommandInfo(cmdText, parameters));
#endif

            IDbCommand cmd = this.DbCommand;

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

            this.Activate();

            IDataReader reader = new InternalDataReader(this, cmd.ExecuteReader(behavior), cmd, outputParameters);
            return(reader);
        }