public void SetUp()
 {
     testee        = new DataReaderExtender();
     _mockery      = new MockRepository();
     _dataReader   = _mockery.StrictMock <IDataReader>();
     _ordinalCache = _mockery.StrictMock <IDataRecordOrdinalCache>();
 }
 [SetUp] public void SetUp()
 {
     _mockery = new MockRepository();
     _testee  = new ExtendedDataReaderWrapper();
     _wrapped = _mockery.StrictMock <IDataReader>();
     _cache   = _mockery.StrictMock <IDataRecordOrdinalCache>();
 }
Ejemplo n.º 3
0
 public void SetUp()
 {
     _mockery             = new MockRepository();
     _adoOperations       = _mockery.StrictMock <IAdoOperations>();
     _ordinalCache        = _mockery.StrictMock <IDataRecordOrdinalCache>();
     _rowCallback         = _mockery.StrictMock <IRowCallback>();
     _rowCallbackDelegate = _mockery.StrictMock <RowCallbackDelegate>();
 }
 private static IResultSetExtractor MakeResultSetExtractor(
     RowCallbackDelegate rowCallbackDelegate, IDataRecordOrdinalCache ordinalCache, int rowsExpected)
 {
     return(new ExtendedRowCallbackResultSetExtractor(rowCallbackDelegate)
     {
         OrdinalCache = ordinalCache,
         RowsExpected = rowsExpected
     });
 }
 private static IResultSetExtractor <IList <T> > MakeResultSetExtractor <T>(
     RowMapperDelegate <T> rowMapperDelegate, IDataRecordOrdinalCache ordinalCache, int rowsExpected)
 {
     return(new ExtendedRowMapperResultSetExtractor <T>(rowMapperDelegate)
     {
         OrdinalCache = ordinalCache,
         RowsExpected = rowsExpected
     });
 }
        /// <summary>
        /// Query database with given SQL command and have each row processed
        /// by a given <see cref="IRowCallback"/> with help of optional
        /// ordinal cache and/or the rows expected value for better performance.
        /// </summary>
        ///
        /// <param name="operations">
        /// An <see cref="Spring.Data.Generic.IAdoOperations"/> object to
        /// perform database operation.
        /// </param>
        /// <param name="cmdType">
        /// The type of command.
        /// </param>
        /// <param name="cmdText">
        /// The text of command.
        /// </param>
        /// <param name="rowCallback">
        /// The row callback that processes each row.
        /// </param>
        /// <param name="ordinalCache">
        /// The <see cref="IDataRecordOrdinalCache"/> that caches the mapping
        /// from field name to field index.
        /// </param>
        /// <param name="rowsExpected">
        /// Number of rows this query is expected to return. This doesn't need
        /// to be accurate but estimating at the higer end for best performance.
        /// </param>
        public static void QueryWithRowCallback(
            this IAdoOperations operations,
            CommandType cmdType,
            string cmdText,
            IRowCallback rowCallback,
            IDataRecordOrdinalCache ordinalCache,
            int rowsExpected)
        {
            var extractor = MakeResultSetExtractor(rowCallback, ordinalCache, rowsExpected);

            operations.QueryWithResultSetExtractor(cmdType, cmdText, extractor);
        }
        /// <summary>
        /// Query database with given SQL command and mapping each row to a
        /// object via a <see cref="RowMapperDelegate{T}"/> with help of optional
        /// ordinal cache and/or the rows expected value for better performance.
        /// </summary>
        /// <typeparam name="T">The type of object that each row maps to.</typeparam>
        /// <param name="operations">
        /// An <see cref="Spring.Data.Generic.IAdoOperations"/> object to
        /// perform database operation.
        /// </param>
        /// <param name="cmdType">
        /// The type of command.
        /// </param>
        /// <param name="cmdText">
        /// The text of command.
        /// </param>
        /// <param name="rowMapperDelegate">
        /// The row mapper delegate that maps each row to object of type
        /// <typeparamref name="T"/>.
        /// </param>
        /// <param name="ordinalCache">
        /// The <see cref="IDataRecordOrdinalCache"/> that caches the mapping
        /// from field name to field index.
        /// </param>
        /// <param name="rowsExpected">
        /// Number of rows this query is expected to return. This doesn't need
        /// to be accurate but estimating at the higer end for best performance.
        /// </param>
        /// <returns>
        /// A list of object of type <typeparamref name="T"/> that were mapped
        /// for the rows.
        /// </returns>
        public static IList <T> QueryWithRowMapperDelegate <T>(
            this IAdoOperations operations,
            CommandType cmdType,
            string cmdText,
            RowMapperDelegate <T> rowMapperDelegate,
            IDataRecordOrdinalCache ordinalCache,
            int rowsExpected)
        {
            var extractor = MakeResultSetExtractor(rowMapperDelegate, ordinalCache, rowsExpected);

            return(operations.QueryWithResultSetExtractor(cmdType, cmdText, extractor));
        }
        /// <summary>
        /// Query database with given SQL command and have each row processed
        /// by a given <see cref="RowCallbackDelegate"/> with help of optional
        /// ordinal cache and/or the rows expected value for better performance.
        /// </summary>
        ///
        /// <param name="operations">
        /// An <see cref="Spring.Data.Generic.IAdoOperations"/> object to
        /// perform database operation.
        /// </param>
        /// <param name="cmdType">
        /// The type of command.
        /// </param>
        /// <param name="cmdText">
        /// The text of command.
        /// </param>
        /// <param name="rowCallbackDelegate">
        /// The row callback delegate that processes each row.
        /// </param>
        /// <param name="parameters">
        /// The parameters with all neccessary values populated.
        /// </param>
        /// <param name="ordinalCache">
        /// The <see cref="IDataRecordOrdinalCache"/> that caches the mapping
        /// from field name to field index.
        /// </param>
        /// <param name="rowsExpected">
        /// Number of rows this query is expected to return. This doesn't need
        /// to be accurate but estimating at the higer end for best performance.
        /// </param>
        public static void QueryWithRowCallbackDelegate(
            this IAdoOperations operations,
            CommandType cmdType,
            string cmdText,
            RowCallbackDelegate rowCallbackDelegate,
            IDbParameters parameters,
            IDataRecordOrdinalCache ordinalCache,
            int rowsExpected)
        {
            var extractor = MakeResultSetExtractor(rowCallbackDelegate, ordinalCache, rowsExpected);

            operations.QueryWithResultSetExtractor(cmdType, cmdText, extractor, parameters);
        }
        /// <summary>
        /// Query database with given SQL command and have each row processed
        /// by a given <see cref="IRowCallback"/> with help of optional
        /// ordinal cache and/or the rows expected value for better performance.
        /// </summary>
        ///
        /// <param name="operations">
        /// An <see cref="Spring.Data.Generic.IAdoOperations"/> object to
        /// perform database operation.
        /// </param>
        /// <param name="cmdType">
        /// The type of command.
        /// </param>
        /// <param name="cmdText">
        /// The text of command.
        /// </param>
        /// <param name="rowCallback">
        /// The row callback that processes each row.
        /// </param>
        /// <param name="parameterValue">
        /// The value of the parameter.
        /// </param>
        /// <param name="ordinalCache">
        /// The <see cref="IDataRecordOrdinalCache"/> that caches the mapping
        /// from field name to field index.
        /// </param>
        /// <param name="parameterName">
        /// The name of the parameter.
        /// </param>
        /// <param name="rowsExpected">
        /// Number of rows this query is expected to return. This doesn't need
        /// to be accurate but estimating at the higer end for best performance.
        /// </param>
        /// <param name="dbType">
        /// Type type of the parameter.
        /// </param>
        /// <param name="size">
        /// The size of parameter.
        /// </param>
        public static void QueryWithRowCallback(
            this IAdoOperations operations,
            CommandType cmdType,
            string cmdText,
            IRowCallback rowCallback,
            string parameterName, Enum dbType, int size, object parameterValue,
            IDataRecordOrdinalCache ordinalCache,
            int rowsExpected)
        {
            var extractor = MakeResultSetExtractor(rowCallback, ordinalCache, rowsExpected);

            operations.QueryWithResultSetExtractor(
                cmdType, cmdText, extractor, parameterName, dbType, size, parameterValue);
        }
        public static IList <T> QueryWithRowMapperDelegate <T>(
            this IAdoOperations operations,
            CommandType cmdType,
            string cmdText,
            RowMapperDelegate <T> rowMapperDelegate,
            Action <IDbCommand> commandSetterDelegate,
            IDataRecordOrdinalCache ordinalCache,
            int rowsExpected)
        {
            var commandSetter = new DelegateCommandSetter(commandSetterDelegate);

            return(QueryWithRowMapperDelegate(operations, cmdType, cmdText, rowMapperDelegate,
                                              commandSetter, ordinalCache, rowsExpected));
        }
        /// <summary>
        /// Query database with given SQL command and mapping each row to a
        /// object via a <see cref="IRowMapper{T}"/> with help of optional
        /// ordinal cache and/or the rows expected value for better performance.
        /// </summary>
        /// <typeparam name="T">The type of object that each row maps to.</typeparam>
        /// <param name="operations">
        /// An <see cref="Spring.Data.Generic.IAdoOperations"/> object to
        /// perform database operation.
        /// </param>
        /// <param name="cmdType">
        /// The type of command.
        /// </param>
        /// <param name="cmdText">
        /// The text of command.
        /// </param>
        /// <param name="rowMapper">
        /// The row mapper that maps each row to object of type
        /// <typeparamref name="T"/>.
        /// </param>
        /// <param name="parameterValue">
        /// The value of the parameter.
        /// </param>
        /// <param name="ordinalCache">
        /// The <see cref="IDataRecordOrdinalCache"/> that caches the mapping
        /// from field name to field index.
        /// </param>
        /// <param name="parameterName">
        /// The name of the parameter.
        /// </param>
        /// <param name="rowsExpected">
        /// Number of rows this query is expected to return. This doesn't need
        /// to be accurate but estimating at the higer end for best performance.
        /// </param>
        /// <param name="dbType">
        /// Type type of the parameter.
        /// </param>
        /// <param name="size">
        /// The size of parameter.
        /// </param>
        /// <returns>
        /// A list of object of type <typeparamref name="T"/> that were mapped
        /// for the rows.
        /// </returns>
        public static IList <T> QueryWithRowMapper <T>(
            this IAdoOperations operations,
            CommandType cmdType,
            string cmdText,
            IRowMapper <T> rowMapper,
            string parameterName, Enum dbType, int size, object parameterValue,
            IDataRecordOrdinalCache ordinalCache,
            int rowsExpected)
        {
            var extractor = MakeResultSetExtractor(rowMapper, ordinalCache, rowsExpected);

            return(operations.QueryWithResultSetExtractor(
                       cmdType, cmdText, extractor, parameterName, dbType, size, parameterValue));
        }