#region Apache Notice /***************************************************************************** * $Revision: 374175 $ * $LastChangedDate$ * $LastChangedBy$ * * iBATIS.NET Data Mapper * Copyright (C) 2008/2005 - The Apache Software Foundation * * * 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 using System.Collections; using System.Collections.Generic; using System.Data; using Apache.Ibatis.DataMapper.Exceptions; namespace Apache.Ibatis.DataMapper { /// /// Main interface the the dataMapper /// public interface IDataMapper { /// /// Executes a Sql DELETE statement. /// Delete returns the number of rows effected. /// /// The name of the statement to execute. /// The parameter object. /// The number of rows effected. int Delete(string statementName, object parameterObject); /// /// Executes a Sql INSERT statement. /// Insert is a bit different from other update methods, as it /// provides facilities for returning the primary key of the /// newly inserted row (rather than the effected rows). This /// functionality is of course optional. ///

/// The parameter object is generally used to supply the input /// data for the INSERT values. ///

/// The name of the statement to execute. /// The parameter object. /// The primary key of the newly inserted row. /// This might be automatically generated by the RDBMS, /// or selected from a sequence table or other source. /// object Insert(string statementName, object parameterObject); /// /// Alias to QueryForMap, .NET spirit. /// Feature idea by Ted Husted. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// The property of the result object to be used as the value (or null) /// A IDictionary (Hashtable) of object containing the rows keyed by keyProperty. ///If a transaction is not in progress, or the database throws an exception. IDictionary QueryForDictionary(string statementName, object parameterObject, string keyProperty, string valueProperty); /// /// Alias to QueryForMap, .NET spirit. /// Feature idea by Ted Husted. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// A IDictionary (Hashtable) of object containing the rows keyed by keyProperty. IDictionary QueryForDictionary(string statementName, object parameterObject, string keyProperty); /// /// Executes a Sql SELECT statement that returns data to populate /// a number of result objects. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// An Ilist object used to hold the objects. /// A List of result objects. void QueryForList(string statementName, object parameterObject, IList resultObject); /// /// Executes a Sql SELECT statement that returns data to populate /// a number of result objects. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// A List of result objects. IList QueryForList(string statementName, object parameterObject); /// /// Executes the SQL and retuns all rows selected in a map that is keyed on the property named /// in the keyProperty parameter. The value at each key will be the entire result object. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// A IDictionary (Hashtable) of object containing the rows keyed by keyProperty. IDictionary QueryForMap(string statementName, object parameterObject, string keyProperty); /// /// Executes the SQL and retuns all rows selected in a map that is keyed on the property named /// in the keyProperty parameter. The value at each key will be the value of the property specified /// in the valueProperty parameter. If valueProperty is null, the entire result object will be entered. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// The property of the result object to be used as the value (or null) /// A IDictionary (Hashtable) of object containing the rows keyed by keyProperty. ///If a transaction is not in progress, or the database throws an exception. IDictionary QueryForMap(string statementName, object parameterObject, string keyProperty, string valueProperty); /// /// Runs a query with a custom object that gets a chance to deal /// with each row as it is processed. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// The property of the result object to be used as the value (or null) /// /// A IDictionary (Hashtable) of object containing the rows keyed by keyProperty. ///If a transaction is not in progress, or the database throws an exception. IDictionary QueryForMapWithRowDelegate(string statementName, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate); /// /// Executes a Sql SELECT statement that returns a single object of the type of the /// resultObject parameter. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// An object of the type to be returned. /// The single result object populated with the result set data. object QueryForObject(string statementName, object parameterObject, object resultObject); /// /// Executes a Sql SELECT statement that returns that returns data /// to populate a single object instance. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The single result object populated with the result set data. object QueryForObject(string statementName, object parameterObject); /// /// Runs a query for list with a custom object that gets a chance to deal /// with each row as it is processed. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// /// A List of result objects. IList QueryWithRowDelegate(string statementName, object parameterObject, RowDelegate rowDelegate); /// /// Executes a Sql UPDATE statement. /// Update can also be used for any other update statement type, /// such as inserts and deletes. Update returns the number of /// rows effected. ///

/// The parameter object is generally used to supply the input /// data for the UPDATE values as well as the WHERE clause parameter(s). ///

/// The name of the statement to execute. /// The parameter object. /// The number of rows effected. int Update(string statementName, object parameterObject); /// /// Executes the SQL and retuns all rows selected in a map that is keyed on the property named /// in the keyProperty parameter. The value at each key will be the value of the property specified /// in the valueProperty parameter. If valueProperty is null, the entire result object will be entered. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// The property of the result object to be used as the value (or null) /// A IDictionary of object containing the rows keyed by keyProperty. ///If a transaction is not in progress, or the database throws an exception. IDictionary QueryForDictionary(string statementName, object parameterObject, string keyProperty, string valueProperty); /// /// Executes the SQL and retuns all rows selected in a map that is keyed on the property named /// in the keyProperty parameter. The value at each key will be the entire result object. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// A IDictionary of object containing the rows keyed by keyProperty. IDictionary QueryForDictionary(string statementName, object parameterObject, string keyProperty); /// /// Runs a query with a custom object that gets a chance to deal /// with each row as it is processed. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The property of the result object to be used as the key. /// The property of the result object to be used as the value (or null) /// A delegate called once per row in the QueryForDictionary method> /// A IDictionary (Hashtable) of object containing the rows keyed by keyProperty. ///If a transaction is not in progress, or the database throws an exception. IDictionary QueryForDictionary(string statementName, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate); /// /// Executes a Sql SELECT statement that returns a single object of the type of the /// resultObject parameter. /// /// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// An object of the type to be returned. /// The single result object populated with the result set data. T QueryForObject(string statementName, object parameterObject, T instanceObject); /// /// Executes a Sql SELECT statement that returns that returns data /// to populate a single object instance. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// The single result object populated with the result set data. T QueryForObject(string statementName, object parameterObject); /// /// Executes a Sql SELECT statement that returns data to populate /// a number of result objects. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// A List of result objects. IList QueryForList(string statementName, object parameterObject); /// /// Executes a Sql SELECT statement that returns data to populate /// a number of result objects. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// An Ilist object used to hold the objects. void QueryForList(string statementName, object parameterObject, IList resultObject); /// /// Runs a query for list with a custom object that gets a chance to deal /// with each row as it is processed. ///

/// The parameter object is generally used to supply the input /// data for the WHERE clause parameter(s) of the SELECT statement. ///

/// The name of the sql statement to execute. /// The object used to set the parameters in the SQL. /// /// A List of result objects. IList QueryWithRowDelegate(string statementName, object parameterObject, RowDelegate rowDelegate); /// /// Executes a SQL SELECT statement that returns data /// to populate a DataTable. /// If a resultMap is specified, the column name will be the result property name. /// /// The statement id. /// The parameter object. /// A DataTable DataTable QueryForDataTable(string statementId, object parameterObject); } }