public void ExecuteQueryWithResultSetExtractor()
        {
            IResultSetExtractor rse = new TestObjectExtractor();
            String sql            = "select USER_ID, USER_NAME from USER_TABLE";
            IList  testObjectList = (IList)adoOperations.QueryWithResultSetExtractor(CommandType.Text, sql, rse);

            Assert.AreEqual(18, testObjectList.Count);
        }
        /// <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);
        }
示例#5
0
 public void QueryWithRowCallback(CommandType commandType, int rowsExpected)
 {
     Expect.Call(_adoOperations.QueryWithResultSetExtractor(CommandType.Text, _sql, null))
     .Return(null)
     .Callback(new Func <CommandType, string, IResultSetExtractor, bool>(
                   (cmdType, sql, extractor) =>
                   cmdType == commandType &&
                   ReferenceEquals(sql, _sql) &&
                   ValidateExtendedRowCallbackResultSetExtractor(extractor)
                   ));
     _mockery.ReplayAll();
     _rowsExpected = rowsExpected;
     _adoOperations.QueryWithRowCallback(
         commandType, _sql, _rowCallback, _ordinalCache, rowsExpected);
     _mockery.VerifyAll();
 }
        /// <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);
        }
        /// <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));
        }