Пример #1
0
        /// <summary>
        /// Executes stored procedure that returns a data reader and passes this
        /// data reader to specified handler.
        /// </summary>
        /// <param name="procedureName">Name of stored procedure to execute.</param>
        /// <param name="commandParameters">Parameters of stored procedure.</param>
        /// <param name="dataReaderHandler">Delegate that accepts the data reader
        /// and reads results from it.</param>
        protected void Execute_Reader(
            string procedureName,
            List <SqlParameter> commandParameters,
            Action <DataReaderAdapter> dataReaderHandler)
        {
            if (procedureName == null)
            {
                throw new ArgumentNullException("procedureName");
            }

            try
            {
                using (DataReaderAdapter reader = DbHelper.ExecuteReaderEx(DatabaseAlias, procedureName, commandParameters))
                {
                    dataReaderHandler(reader);
                }
            }
            catch (SqlException e)
            {
                ThrowRecognisedException(e, procedureName, commandParameters);
                throw;
            }
        }