diff --git a/src/Spring/Spring.Data/Data/Generic/IAdoOperations.cs b/src/Spring/Spring.Data/Data/Generic/IAdoOperations.cs index ea7ad2fd..cfb4c570 100644 --- a/src/Spring/Spring.Data/Data/Generic/IAdoOperations.cs +++ b/src/Spring/Spring.Data/Data/Generic/IAdoOperations.cs @@ -104,39 +104,39 @@ namespace Spring.Data.Generic /// A result object returned by the callback or null T Execute(DataAdapterDelegate del); - #endregion + #endregion #region Queries with RowMapper IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper); - IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, + IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, ICommandSetter commandSetter); IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, string parameterName, Enum dbType, int size, object parameterValue); - IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, + IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, IDbParameters parameters); #endregion - + #region Queries with RowMapperDelegate IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate); IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, ICommandSetter commandSetter); - - + + IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, string parameterName, Enum dbType, int size, object parameterValue); - + IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, IDbParameters parameters); - + #endregion #region Queries with ResultSetExtractor @@ -183,12 +183,12 @@ namespace Spring.Data.Generic T QueryForObject(CommandType cmdType, string sql, IRowMapper rowMapper, IDbParameters parameters); - - + + T QueryForObject(CommandType cmdType, string sql, IRowMapper rowMapper, string name, Enum dbType, int size, object parameterValue); - - + + #endregion @@ -228,6 +228,50 @@ namespace Spring.Data.Generic #endregion + #region Parameter Creation Helper Methods + + IDbParameters CreateDbParameters(); + + /// + /// Note that output parameters are marked input/output after derivation.... + /// (TODO - double check....) + /// + /// + /// + IDataParameter[] DeriveParameters(string procedureName); + + IDataParameter[] DeriveParameters(string procedureName, bool includeReturnParameter); + + #endregion + + #region Behavioral Control Properties + + /// + /// An instance of a DbProvider implementation. + /// + IDbProvider DbProvider { get; set; } + + /// + /// Gets or set the System.Type to use to create an instance of IDataReaderWrapper + /// for the purpose of having defaults values to use in case of DBNull values read + /// from IDataReader. + /// + /// The type of the data reader wrapper. + Type DataReaderWrapperType { get; set; } + + /// + /// Gets or sets the command timeout for IDbCommands that this AdoTemplate executes. + /// + /// Default is 0, indicating to use the database provider's default. + /// Any timeout specified here will be overridden by the remaining + /// transaction timeout when executing within a transaction that has a + /// timeout specified at the transaction level. + /// + /// The command timeout. + int CommandTimeout { get; set; } + + + #endregion } } diff --git a/src/Spring/Spring.Data/Data/IAdoOperations.cs b/src/Spring/Spring.Data/Data/IAdoOperations.cs index 91fcb4eb..8eb7c0ef 100644 --- a/src/Spring/Spring.Data/Data/IAdoOperations.cs +++ b/src/Spring/Spring.Data/Data/IAdoOperations.cs @@ -1,121 +1,121 @@ -#region License - -/* - * Copyright © 2002-2011 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#endregion - -#region Imports - -using System; -using System.Collections; -using System.Data; -using Spring.Data.Common; - -#endregion - -namespace Spring.Data -{ - /// - /// Interface that defines ADO.NET related database operations. - /// - /// Mark Pollack (.NET) - public interface IAdoOperations : ICommonAdoOperations - { - - #region General Execute Methods with Callbacks - /// - /// Execute a ADO.NET operation on a command object using a delegate callback. - /// - /// This allows for implementing arbitrary data access operations - /// on a single command within Spring's managed ADO.NET environment. - /// The delegate called with a command object. - /// A result object returned by the action or null - object Execute(CommandDelegate del); - - /// - /// Execute a ADO.NET operation on a command object using an interface based callback. - /// - /// the callback to execute - /// object returned from callback - object Execute(ICommandCallback action); - - /// - /// Executes ADO.NET operations on a command object, created by the provided IDbCommandCreator, - /// using the interface based callback IDbCommandCallback. - /// - /// The command creator. - /// The callback to execute based on IDbCommand - /// A result object returned by the action or null - object Execute(IDbCommandCreator commandCreator, ICommandCallback action); - - /// - /// Execute ADO.NET operations on a IDbDataAdapter object using an interface based callback. - /// - /// This allows for implementing abritrary data access operations - /// on a single DataAdapter within Spring's managed ADO.NET environment. - /// - /// The data adapter callback. - /// A result object returned by the callback or null - object Execute(IDataAdapterCallback dataAdapterCallback); - - #endregion - - - - - - #region Queries With ResultSetExtractor - - // Static Queries - - /// - /// Execute a query given IDbCommand's type and text, processing a - /// single result set with an instance of IResultSetExtractor - /// - /// The type of command - /// The text of the query. - /// Object that will extract all rows of a result set - /// An arbitrary result object, as returned by the IResultSetExtractor - /// - /// If there is any problem executing the query. - /// - object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor); - - - // Parameterized Queries - // Only input parameters can be used... - - - /// - /// Execute a query given the CommandType and text with parameters set - /// via the command setter, processing a - /// single result set with an instance of IResultSetExtractor +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +#region Imports + +using System; +using System.Collections; +using System.Data; +using Spring.Data.Common; + +#endregion + +namespace Spring.Data +{ + /// + /// Interface that defines ADO.NET related database operations. + /// + /// Mark Pollack (.NET) + public interface IAdoOperations : ICommonAdoOperations + { + + #region General Execute Methods with Callbacks + /// + /// Execute a ADO.NET operation on a command object using a delegate callback. /// - /// The command type. - /// The command text to execute. - /// The result set extractor. - /// The command setter. - /// An arbitrary result object, as returned by the IResultSetExtractor - /// - /// If there is any problem executing the query. + /// This allows for implementing arbitrary data access operations + /// on a single command within Spring's managed ADO.NET environment. + /// The delegate called with a command object. + /// A result object returned by the action or null + object Execute(CommandDelegate del); + + /// + /// Execute a ADO.NET operation on a command object using an interface based callback. + /// + /// the callback to execute + /// object returned from callback + object Execute(ICommandCallback action); + + /// + /// Executes ADO.NET operations on a command object, created by the provided IDbCommandCreator, + /// using the interface based callback IDbCommandCallback. + /// + /// The command creator. + /// The callback to execute based on IDbCommand + /// A result object returned by the action or null + object Execute(IDbCommandCreator commandCreator, ICommandCallback action); + + /// + /// Execute ADO.NET operations on a IDbDataAdapter object using an interface based callback. + /// + /// This allows for implementing abritrary data access operations + /// on a single DataAdapter within Spring's managed ADO.NET environment. + /// + /// The data adapter callback. + /// A result object returned by the callback or null + object Execute(IDataAdapterCallback dataAdapterCallback); + + #endregion + + + + + + #region Queries With ResultSetExtractor + + // Static Queries + + /// + /// Execute a query given IDbCommand's type and text, processing a + /// single result set with an instance of IResultSetExtractor + /// + /// The type of command + /// The text of the query. + /// Object that will extract all rows of a result set + /// An arbitrary result object, as returned by the IResultSetExtractor + /// + /// If there is any problem executing the query. /// - object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor, - ICommandSetter commandSetter); - + object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor); + + + // Parameterized Queries + // Only input parameters can be used... + + + /// + /// Execute a query given the CommandType and text with parameters set + /// via the command setter, processing a + /// single result set with an instance of IResultSetExtractor + /// + /// The command type. + /// The command text to execute. + /// The result set extractor. + /// The command setter. + /// An arbitrary result object, as returned by the IResultSetExtractor + /// + /// If there is any problem executing the query. + /// + object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor, + ICommandSetter commandSetter); + /// /// Execute a query given the CommandType and text specifying a single parameter and process a single result set with an /// instance of IResultSetExtractor. @@ -133,7 +133,7 @@ namespace Spring.Data /// /// If there is any problem executing the query. /// - object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor, + object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor, string parameterName, Enum dbType, int size, object parameterValue); /// @@ -148,31 +148,31 @@ namespace Spring.Data /// /// If there is any problem executing the query. /// - object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor, - IDbParameters parameters); - - - #endregion - - #region Queries With ResultSetExtractorDelegate - - // Static Queries - - /// - /// Execute a query given static SQL/Stored Procedure name - /// and process a single result set with an instance of ResultSetExtractorDelegate - /// - /// The type of command. + object QueryWithResultSetExtractor(CommandType cmdType, string cmdText, IResultSetExtractor resultSetExtractor, + IDbParameters parameters); + + + #endregion + + #region Queries With ResultSetExtractorDelegate + + // Static Queries + + /// + /// Execute a query given static SQL/Stored Procedure name + /// and process a single result set with an instance of ResultSetExtractorDelegate + /// + /// The type of command. /// The command text. - /// Delegate that will process all rows of a result set - /// An arbitrary result object, as returned by the IResultSetExtractor - /// - /// If there is any problem executing the query. - /// - object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate); - - - // Parameterized Queries + /// Delegate that will process all rows of a result set + /// An arbitrary result object, as returned by the IResultSetExtractor + /// + /// If there is any problem executing the query. + /// + object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate); + + + // Parameterized Queries // only input parameters can be used... /// @@ -188,7 +188,7 @@ namespace Spring.Data /// /// If there is any problem executing the query. /// - object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, + object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, ICommandSetter commandSetter); @@ -209,7 +209,7 @@ namespace Spring.Data /// /// If there is any problem executing the query. /// - object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, + object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, string parameterName, Enum dbType, int size, object parameterValue); /// @@ -224,12 +224,12 @@ namespace Spring.Data /// /// If there is any problem executing the query. /// - object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, - IDbParameters parameters); - - - #endregion - + object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, + IDbParameters parameters); + + + #endregion + #region Queries with RowMapperDelegate /// @@ -239,537 +239,565 @@ namespace Spring.Data /// The type of command /// SQL query to execute /// delegate/lambda that will map one object per row - /// The result list containing mapped objects - IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate); - - IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate, ICommandSetter commandSetter); - - IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate, - string parameterName, Enum dbType, int size, object parameterValue); - - IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate, IDbParameters parameter); - - - #endregion - - #region Queries with RowMapper - - // Static Queries - - - /// - /// Execute a query given static SQL, mapping each row to a .NET object - /// via a RowMapper - /// - /// The type of command - /// SQL query to execute - /// object that will map one object per row - /// the result list containing mapped objects - IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper); - - // Parameterized Queries - - //Using IRowMapper to process 1 result set - IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, ICommandSetter commandSetter); - - IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, - string name, Enum dbType, int size, object parameterValue); - - IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, IDbParameters parameter); - - - - #endregion - - #region Query for Object - - - - - - /// - /// Execute a query with the specified command text, mapping a single result - /// row to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// object that will map one object per row - /// The single mapped object. - /// - /// If the query does not return exactly one row. - /// - /// - /// If there is any problem executing the query. - /// - object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper); - - - /// - /// Execute a query with the specified command text and parameters set via the - /// command setter, mapping a single result row to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// object that will map one object per row - /// The command setter. - /// The single mapped object. - /// - /// If the query does not return exactly one row. - /// - /// - /// If there is any problem executing the query. - /// - object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper, ICommandSetter commandSetter); - - /// - /// Execute a query with the specified command text and parameters, mapping a single result row - /// to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// object that will map one object per row - /// The parameter collection to use in the query. - /// The single mapped object. - /// - /// If the query does not return exactly one row. - /// - /// - /// If there is any problem executing the query. - /// - object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper, IDbParameters parameters); - - /// - /// Execute a query with the specified command text and parameter, mapping a single result row - /// to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// object that will map one object per row - /// The name of the parameter to map. - /// One of the database parameter type enumerations. - /// The length of the parameter. 0 if not applicable to parameter type. - /// The parameter value. - /// The single mapped object. - /// - /// If the query does not return exactly one row. - /// - /// - /// If there is any problem executing the query. - /// - object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper, - string parameterName, Enum dbType, int size, object parameterValue); - - - #endregion - - #region Query for ObjectDelegate - - /// - /// Execute a query with the specified command text, mapping a single result - /// row to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// delegate that will map one object per row - /// The single mapped object. - /// - /// If the query does not return exactly one row. - /// - /// - /// If there is any problem executing the query. - /// - object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate); - - - - /// - /// Execute a query with the specified command text and parameters set via the - /// command setter, mapping a single result row to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// delegate that will map one object per row - /// The command setter. - /// The single mapped object. - /// - /// If the query does not return exactly one row. - /// - /// - /// If there is any problem executing the query. - /// - object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, ICommandSetter commandSetter); - - - /// - /// Execute a query with the specified command text and parameters, mapping a single result row - /// to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// delegate that will map one object per row - /// The parameter collection to use in the query. - /// The single mapped object. - /// - /// If the query does not return exactly one row. - /// - /// - /// If there is any problem executing the query. - /// - object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, IDbParameters parameters); - - - /// - /// Execute a query with the specified command text and parameter, mapping a single result row - /// to an object via a RowMapper. - /// - /// The command type. - /// The command text to execute. - /// delegate that will map one object per row - /// The name of the parameter to map. - /// One of the database parameter type enumerations. - /// The length of the parameter. 0 if not applicable to parameter type. - /// The parameter value. - /// - object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, - string parameterName, Enum dbType, int size, object parameterValue); - - - #endregion - - #region Query With CommandCreator - - // Using IResultSetExtractor to process one result set. - object QueryWithCommandCreator(IDbCommandCreator commandCreator, IResultSetExtractor resultSetExtractor); - - IList QueryWithCommandCreator(IDbCommandCreator cc, IRowMapper rowMapper); - - // Using IResultSetExtractor to return one result set, multiple output parameters. - object QueryWithCommandCreator(IDbCommandCreator commandCreator, IResultSetExtractor resultSetExtractor, IDictionary returnedParameters); - - // Using IRowMapper to return one result set, multiple output parameters. - IList QueryWithCommandCreator(IDbCommandCreator commandCreator, IRowMapper rowMapper, IDictionary returnedParameters); - - - // Multiple return result sets, (A list of lists) - // each with either a IRowMapper, IResultSetExtractor, IRowCallback - // and multiple output parameters. - IDictionary QueryWithCommandCreator(IDbCommandCreator commandCreator, IList resultProcessors); - - #endregion - - #region DataTable Create operations without parameters - - DataTable DataTableCreate(CommandType commandType, string sql); - - DataTable DataTableCreate(CommandType commandType, string sql, - string tableMappingName); - - DataTable DataTableCreate(CommandType commandType, string sql, - ITableMapping tableMapping); - - DataTable DataTableCreate(CommandType commandType, string sql, - ITableMapping tableMapping, - IDataAdapterSetter setter); - - #endregion - - #region DataTable Create operations with parameters - - DataTable DataTableCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters); - - DataTable DataTableCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters, - string tableMappingName); - - DataTable DataTableCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters, - ITableMapping tableMapping); - - DataTable DataTableCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters, - ITableMapping tableMapping, - IDataAdapterSetter dataAdapterSetter); - - - - #endregion - - #region DataTable Fill operations without parameters - /// - /// Fill a based on a select command that requires no parameters. - /// - /// The to populate - /// The type of command - /// SQL query to execute - /// The number of rows successfully added to or refreshed in the - int DataTableFill(DataTable dataTable, CommandType commandType, string sql); - - int DataTableFill(DataTable dataTable, CommandType commandType, string sql, - string tableMappingName); - - int DataTableFill(DataTable dataTable, CommandType commandType, string sql, - ITableMapping tableMapping); - - int DataTableFill(DataTable dataTable, CommandType commandType, string sql, - ITableMapping tableMapping, - IDataAdapterSetter setter); - - - #endregion - - #region DataTable Fill operations with parameters - - int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, - IDbParameters parameters); - - int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, - IDbParameters parameters, - string tableName); - - int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, - IDbParameters parameters, - ITableMapping tableMapping); - - int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, - IDbParameters parameters, - ITableMapping tableMapping, - IDataAdapterSetter dataAdapterSetter); - - #endregion - - #region DataTable Update operations - - int DataTableUpdateWithCommandBuilder(DataTable dataTable, - CommandType commandType, - string selectSql, - IDbParameters parameters, - string tableName); - - int DataTableUpdateWithCommandBuilder(DataTable dataTable, - CommandType commandType, - string selectSql, - IDbParameters parameters, - string tableName, - IDataAdapterSetter dataAdapterSetter); - - int DataTableUpdateWithCommandBuilder(DataTable dataTable, - CommandType commandType, - string selectSql, - IDbParameters parameters, - ITableMapping tableMapping, - IDataAdapterSetter dataAdapterSetter); - - int DataTableUpdate(DataTable dataTable, - string tableName, - CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, - CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, - CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters); - - int DataTableUpdate(DataTable dataTable, - string tableName, - CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, - CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, - CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters, - IDataAdapterSetter dataAdapterSetter); - - int DataTableUpdate(DataTable dataTable, - ITableMapping tableMapping, - CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, - CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, - CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters, - IDataAdapterSetter dataAdapterSetter); - - - - #endregion - - #region DataSet Create operations without parameters - - DataSet DataSetCreate(CommandType commandType, string sql); - - DataSet DataSetCreate(CommandType commandType, string sql, - string[] tableNames); - - DataSet DataSetCreate(CommandType commandType, string sql, - ITableMappingCollection tableMapping); - - DataSet DataSetCreate(CommandType commandType, string sql, - ITableMappingCollection tableMapping, - IDataAdapterSetter setter); - - DataSet DataSetCreate(CommandType commandType, string sql, - ITableMappingCollection tableMapping, - IDataAdapterSetter setter, - IDataSetFillLifecycleProcessor fillLifecycleProcessor); - #endregion - - #region DataSet Create operations with parameters - - DataSet DataSetCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters); - - DataSet DataSetCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters, - string[] tableNames); - - DataSet DataSetCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters, - ITableMappingCollection tableMapping); - - DataSet DataSetCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters, - ITableMappingCollection tableMapping, - IDataAdapterSetter dataAdapterSetter); - - DataSet DataSetCreateWithParams(CommandType commandType, string sql, - IDbParameters parameters, - ITableMappingCollection tableMapping, - IDataAdapterSetter dataAdapterSetter, - IDataSetFillLifecycleProcessor fillLifecycleProcessor); - - #endregion - - #region DataSet Fill operations without parameters - - /// - /// Fill a based on a select command that requires no parameters. - /// - /// The to populate - /// The type of command - /// SQL query to execute - /// The number of rows successfully added to or refreshed in the - int DataSetFill(DataSet dataSet, CommandType commandType, string sql); - - /// - /// Fill a based on a select command that requires no parameters - /// that returns one or more result sets that are added as - /// s to the - /// - /// The to populate - /// The type of command - /// SQL query to execute - /// The mapping of table names for each - /// created - /// - int DataSetFill(DataSet dataSet, CommandType commandType, string sql, - string[] tableNames); - - int DataSetFill(DataSet dataSet, CommandType commandType, string sql, - ITableMappingCollection tableMapping); - - int DataSetFill(DataSet dataSet, CommandType commandType, string sql, - ITableMappingCollection tableMapping, - IDataAdapterSetter setter); - - int DataSetFill(DataSet dataSet, CommandType commandType, string sql, - ITableMappingCollection tableMapping, - IDataAdapterSetter setter, - IDataSetFillLifecycleProcessor fillLifecycleProcessor); - - #endregion - - #region DataSet Fill operations with parameters - - int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, - IDbParameters parameters); - - int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, - IDbParameters parameters, - string[] tableNames); - - int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, - IDbParameters parameters, - ITableMappingCollection tableMapping); - - int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, - IDbParameters parameters, - ITableMappingCollection tableMapping, - IDataAdapterSetter dataAdapterSetter); - - int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, - IDbParameters parameters, - ITableMappingCollection tableMapping, - IDataAdapterSetter dataAdapterSetter, - IDataSetFillLifecycleProcessor fillLifecycleProcessor); - - #endregion - - #region DataSet Update operations - - int DataSetUpdateWithCommandBuilder(DataSet dataSet, - CommandType commandType, - string selectSql, - IDbParameters selectParameters, - string tableName); - - int DataSetUpdateWithCommandBuilder(DataSet dataSet, - CommandType commandType, - string selectSql, - IDbParameters selectParameters, - string tableName, - IDataAdapterSetter dataAdapterSetter); - - int DataSetUpdateWithCommandBuilder(DataSet dataSet, - CommandType commandType, - string selectSql, - IDbParameters selectParameters, - ITableMappingCollection tableMapping, - IDataAdapterSetter dataAdapterSetter); - - - int DataSetUpdate(DataSet dataSet, - string tableName, - IDbCommand insertCommand, - IDbCommand updateCommand, - IDbCommand deleteCommand); - - - int DataSetUpdate(DataSet dataSet, - string tableName, - CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, - CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, - CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters); - - - int DataSetUpdate(DataSet dataSet, - string tableName, - IDbCommand insertCommand, - IDbCommand updateCommand, - IDbCommand deleteCommand, - IDataAdapterSetter dataAdapterSetter); - - int DataSetUpdate(DataSet dataSet, - ITableMappingCollection tableMapping, - IDbCommand insertCommand, - IDbCommand updateCommand, - IDbCommand deleteCommand); - - int DataSetUpdate(DataSet dataSet, - ITableMappingCollection tableMapping, - IDbCommand insertCommand, - IDbCommand updateCommand, - IDbCommand deleteCommand, - IDataAdapterSetter dataAdapterSetter); - - #endregion - - #region Parameter Creation Helper Methods - - IDbParameters CreateDbParameters(); - - /// - /// Note that output parameters are marked input/output after derivation.... - /// (TODO - double check....) - /// - /// - /// - IDataParameter[] DeriveParameters(string procedureName); - - IDataParameter[] DeriveParameters(string procedureName, bool includeReturnParameter); - - #endregion - } - - -} + /// The result list containing mapped objects + IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate); + + IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate, ICommandSetter commandSetter); + + IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate, + string parameterName, Enum dbType, int size, object parameterValue); + + IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate, IDbParameters parameter); + + + #endregion + + #region Queries with RowMapper + + // Static Queries + + + /// + /// Execute a query given static SQL, mapping each row to a .NET object + /// via a RowMapper + /// + /// The type of command + /// SQL query to execute + /// object that will map one object per row + /// the result list containing mapped objects + IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper); + + // Parameterized Queries + + //Using IRowMapper to process 1 result set + IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, ICommandSetter commandSetter); + + IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, + string name, Enum dbType, int size, object parameterValue); + + IList QueryWithRowMapper(CommandType cmdType, string cmdText, IRowMapper rowMapper, IDbParameters parameter); + + + + #endregion + + #region Query for Object + + + + + + /// + /// Execute a query with the specified command text, mapping a single result + /// row to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// object that will map one object per row + /// The single mapped object. + /// + /// If the query does not return exactly one row. + /// + /// + /// If there is any problem executing the query. + /// + object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper); + + + /// + /// Execute a query with the specified command text and parameters set via the + /// command setter, mapping a single result row to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// object that will map one object per row + /// The command setter. + /// The single mapped object. + /// + /// If the query does not return exactly one row. + /// + /// + /// If there is any problem executing the query. + /// + object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper, ICommandSetter commandSetter); + + /// + /// Execute a query with the specified command text and parameters, mapping a single result row + /// to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// object that will map one object per row + /// The parameter collection to use in the query. + /// The single mapped object. + /// + /// If the query does not return exactly one row. + /// + /// + /// If there is any problem executing the query. + /// + object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper, IDbParameters parameters); + + /// + /// Execute a query with the specified command text and parameter, mapping a single result row + /// to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// object that will map one object per row + /// The name of the parameter to map. + /// One of the database parameter type enumerations. + /// The length of the parameter. 0 if not applicable to parameter type. + /// The parameter value. + /// The single mapped object. + /// + /// If the query does not return exactly one row. + /// + /// + /// If there is any problem executing the query. + /// + object QueryForObject(CommandType cmdType, string cmdText, IRowMapper rowMapper, + string parameterName, Enum dbType, int size, object parameterValue); + + + #endregion + + #region Query for ObjectDelegate + + /// + /// Execute a query with the specified command text, mapping a single result + /// row to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// delegate that will map one object per row + /// The single mapped object. + /// + /// If the query does not return exactly one row. + /// + /// + /// If there is any problem executing the query. + /// + object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelgate); + + + + /// + /// Execute a query with the specified command text and parameters set via the + /// command setter, mapping a single result row to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// delegate that will map one object per row + /// The command setter. + /// The single mapped object. + /// + /// If the query does not return exactly one row. + /// + /// + /// If there is any problem executing the query. + /// + object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, ICommandSetter commandSetter); + + + /// + /// Execute a query with the specified command text and parameters, mapping a single result row + /// to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// delegate that will map one object per row + /// The parameter collection to use in the query. + /// The single mapped object. + /// + /// If the query does not return exactly one row. + /// + /// + /// If there is any problem executing the query. + /// + object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, IDbParameters parameters); + + + /// + /// Execute a query with the specified command text and parameter, mapping a single result row + /// to an object via a RowMapper. + /// + /// The command type. + /// The command text to execute. + /// delegate that will map one object per row + /// The name of the parameter to map. + /// One of the database parameter type enumerations. + /// The length of the parameter. 0 if not applicable to parameter type. + /// The parameter value. + /// + object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, + string parameterName, Enum dbType, int size, object parameterValue); + + + #endregion + + #region Query With CommandCreator + + // Using IResultSetExtractor to process one result set. + object QueryWithCommandCreator(IDbCommandCreator commandCreator, IResultSetExtractor resultSetExtractor); + + IList QueryWithCommandCreator(IDbCommandCreator cc, IRowMapper rowMapper); + + // Using IResultSetExtractor to return one result set, multiple output parameters. + object QueryWithCommandCreator(IDbCommandCreator commandCreator, IResultSetExtractor resultSetExtractor, IDictionary returnedParameters); + + // Using IRowMapper to return one result set, multiple output parameters. + IList QueryWithCommandCreator(IDbCommandCreator commandCreator, IRowMapper rowMapper, IDictionary returnedParameters); + + + // Multiple return result sets, (A list of lists) + // each with either a IRowMapper, IResultSetExtractor, IRowCallback + // and multiple output parameters. + IDictionary QueryWithCommandCreator(IDbCommandCreator commandCreator, IList resultProcessors); + + #endregion + + #region DataTable Create operations without parameters + + DataTable DataTableCreate(CommandType commandType, string sql); + + DataTable DataTableCreate(CommandType commandType, string sql, + string tableMappingName); + + DataTable DataTableCreate(CommandType commandType, string sql, + ITableMapping tableMapping); + + DataTable DataTableCreate(CommandType commandType, string sql, + ITableMapping tableMapping, + IDataAdapterSetter setter); + + #endregion + + #region DataTable Create operations with parameters + + DataTable DataTableCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters); + + DataTable DataTableCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters, + string tableMappingName); + + DataTable DataTableCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters, + ITableMapping tableMapping); + + DataTable DataTableCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters, + ITableMapping tableMapping, + IDataAdapterSetter dataAdapterSetter); + + + + #endregion + + #region DataTable Fill operations without parameters + /// + /// Fill a based on a select command that requires no parameters. + /// + /// The to populate + /// The type of command + /// SQL query to execute + /// The number of rows successfully added to or refreshed in the + int DataTableFill(DataTable dataTable, CommandType commandType, string sql); + + int DataTableFill(DataTable dataTable, CommandType commandType, string sql, + string tableMappingName); + + int DataTableFill(DataTable dataTable, CommandType commandType, string sql, + ITableMapping tableMapping); + + int DataTableFill(DataTable dataTable, CommandType commandType, string sql, + ITableMapping tableMapping, + IDataAdapterSetter setter); + + + #endregion + + #region DataTable Fill operations with parameters + + int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, + IDbParameters parameters); + + int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, + IDbParameters parameters, + string tableName); + + int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, + IDbParameters parameters, + ITableMapping tableMapping); + + int DataTableFillWithParams(DataTable dataTable, CommandType commandType, string sql, + IDbParameters parameters, + ITableMapping tableMapping, + IDataAdapterSetter dataAdapterSetter); + + #endregion + + #region DataTable Update operations + + int DataTableUpdateWithCommandBuilder(DataTable dataTable, + CommandType commandType, + string selectSql, + IDbParameters parameters, + string tableName); + + int DataTableUpdateWithCommandBuilder(DataTable dataTable, + CommandType commandType, + string selectSql, + IDbParameters parameters, + string tableName, + IDataAdapterSetter dataAdapterSetter); + + int DataTableUpdateWithCommandBuilder(DataTable dataTable, + CommandType commandType, + string selectSql, + IDbParameters parameters, + ITableMapping tableMapping, + IDataAdapterSetter dataAdapterSetter); + + int DataTableUpdate(DataTable dataTable, + string tableName, + CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, + CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, + CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters); + + int DataTableUpdate(DataTable dataTable, + string tableName, + CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, + CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, + CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters, + IDataAdapterSetter dataAdapterSetter); + + int DataTableUpdate(DataTable dataTable, + ITableMapping tableMapping, + CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, + CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, + CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters, + IDataAdapterSetter dataAdapterSetter); + + + + #endregion + + #region DataSet Create operations without parameters + + DataSet DataSetCreate(CommandType commandType, string sql); + + DataSet DataSetCreate(CommandType commandType, string sql, + string[] tableNames); + + DataSet DataSetCreate(CommandType commandType, string sql, + ITableMappingCollection tableMapping); + + DataSet DataSetCreate(CommandType commandType, string sql, + ITableMappingCollection tableMapping, + IDataAdapterSetter setter); + + DataSet DataSetCreate(CommandType commandType, string sql, + ITableMappingCollection tableMapping, + IDataAdapterSetter setter, + IDataSetFillLifecycleProcessor fillLifecycleProcessor); + #endregion + + #region DataSet Create operations with parameters + + DataSet DataSetCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters); + + DataSet DataSetCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters, + string[] tableNames); + + DataSet DataSetCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters, + ITableMappingCollection tableMapping); + + DataSet DataSetCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters, + ITableMappingCollection tableMapping, + IDataAdapterSetter dataAdapterSetter); + + DataSet DataSetCreateWithParams(CommandType commandType, string sql, + IDbParameters parameters, + ITableMappingCollection tableMapping, + IDataAdapterSetter dataAdapterSetter, + IDataSetFillLifecycleProcessor fillLifecycleProcessor); + + #endregion + + #region DataSet Fill operations without parameters + + /// + /// Fill a based on a select command that requires no parameters. + /// + /// The to populate + /// The type of command + /// SQL query to execute + /// The number of rows successfully added to or refreshed in the + int DataSetFill(DataSet dataSet, CommandType commandType, string sql); + + /// + /// Fill a based on a select command that requires no parameters + /// that returns one or more result sets that are added as + /// s to the + /// + /// The to populate + /// The type of command + /// SQL query to execute + /// The mapping of table names for each + /// created + /// + int DataSetFill(DataSet dataSet, CommandType commandType, string sql, + string[] tableNames); + + int DataSetFill(DataSet dataSet, CommandType commandType, string sql, + ITableMappingCollection tableMapping); + + int DataSetFill(DataSet dataSet, CommandType commandType, string sql, + ITableMappingCollection tableMapping, + IDataAdapterSetter setter); + + int DataSetFill(DataSet dataSet, CommandType commandType, string sql, + ITableMappingCollection tableMapping, + IDataAdapterSetter setter, + IDataSetFillLifecycleProcessor fillLifecycleProcessor); + + #endregion + + #region DataSet Fill operations with parameters + + int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, + IDbParameters parameters); + + int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, + IDbParameters parameters, + string[] tableNames); + + int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, + IDbParameters parameters, + ITableMappingCollection tableMapping); + + int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, + IDbParameters parameters, + ITableMappingCollection tableMapping, + IDataAdapterSetter dataAdapterSetter); + + int DataSetFillWithParameters(DataSet dataSet, CommandType commandType, string sql, + IDbParameters parameters, + ITableMappingCollection tableMapping, + IDataAdapterSetter dataAdapterSetter, + IDataSetFillLifecycleProcessor fillLifecycleProcessor); + + #endregion + + #region DataSet Update operations + + int DataSetUpdateWithCommandBuilder(DataSet dataSet, + CommandType commandType, + string selectSql, + IDbParameters selectParameters, + string tableName); + + int DataSetUpdateWithCommandBuilder(DataSet dataSet, + CommandType commandType, + string selectSql, + IDbParameters selectParameters, + string tableName, + IDataAdapterSetter dataAdapterSetter); + + int DataSetUpdateWithCommandBuilder(DataSet dataSet, + CommandType commandType, + string selectSql, + IDbParameters selectParameters, + ITableMappingCollection tableMapping, + IDataAdapterSetter dataAdapterSetter); + + + int DataSetUpdate(DataSet dataSet, + string tableName, + IDbCommand insertCommand, + IDbCommand updateCommand, + IDbCommand deleteCommand); + + + int DataSetUpdate(DataSet dataSet, + string tableName, + CommandType insertCommandtype, string insertSql, IDbParameters insertParameters, + CommandType updateCommandtype, string updateSql, IDbParameters updateParameters, + CommandType deleteCommandtype, string deleteSql, IDbParameters deleteParameters); + + + int DataSetUpdate(DataSet dataSet, + string tableName, + IDbCommand insertCommand, + IDbCommand updateCommand, + IDbCommand deleteCommand, + IDataAdapterSetter dataAdapterSetter); + + int DataSetUpdate(DataSet dataSet, + ITableMappingCollection tableMapping, + IDbCommand insertCommand, + IDbCommand updateCommand, + IDbCommand deleteCommand); + + int DataSetUpdate(DataSet dataSet, + ITableMappingCollection tableMapping, + IDbCommand insertCommand, + IDbCommand updateCommand, + IDbCommand deleteCommand, + IDataAdapterSetter dataAdapterSetter); + + #endregion + + #region Parameter Creation Helper Methods + + IDbParameters CreateDbParameters(); + + /// + /// Note that output parameters are marked input/output after derivation.... + /// (TODO - double check....) + /// + /// + /// + IDataParameter[] DeriveParameters(string procedureName); + + IDataParameter[] DeriveParameters(string procedureName, bool includeReturnParameter); + + #endregion + + #region Behavioral Control Properties + + /// + /// An instance of a DbProvider implementation. + /// + IDbProvider DbProvider { get; set; } + + /// + /// Gets or set the System.Type to use to create an instance of IDataReaderWrapper + /// for the purpose of having defaults values to use in case of DBNull values read + /// from IDataReader. + /// + /// The type of the data reader wrapper. + Type DataReaderWrapperType { get; set; } + + /// + /// Gets or sets the command timeout for IDbCommands that this AdoTemplate executes. + /// + /// Default is 0, indicating to use the database provider's default. + /// Any timeout specified here will be overridden by the remaining + /// transaction timeout when executing within a transaction that has a + /// timeout specified at the transaction level. + /// + /// The command timeout. + int CommandTimeout { get; set; } + + #endregion + } + + +}