#region Apache Notice /***************************************************************************** * $Header: $ * $Revision$ * $Date$ * * iBATIS.NET Data Mapper * Copyright (C) 2004 - Gilles Bayon * * * 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.Collections; #if dotnet2 using System.Collections.Generic; #endif using IBatisNet.DataMapper.Commands; using IBatisNet.DataMapper.Configuration.Statements; #endregion namespace IBatisNet.DataMapper.MappedStatements { /// /// /// public delegate void ExecuteEventHandler(object sender, ExecuteEventArgs e); /// /// Summary description for IMappedStatement. /// public interface IMappedStatement { #region Event /// /// Event launch on exceute query /// event ExecuteEventHandler Execute; #endregion #region Properties /// /// The IPreparedCommand to use /// IPreparedCommand PreparedCommand { get; } /// /// Name used to identify the MappedStatement amongst the others. /// This the name of the SQL statment by default. /// string Id { get; } /// /// The SQL statment used by this MappedStatement /// IStatement Statement { get; } /// /// The SqlMap used by this MappedStatement /// ISqlMapper SqlMap { get; } #endregion #region ExecuteQueryForMap /// /// 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 session used to execute the statement /// 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 hashtable of object containing the rows keyed by keyProperty. ///If a transaction is not in progress, or the database throws an exception. IDictionary ExecuteQueryForMap( ISqlMapSession session, object parameterObject, string keyProperty, string valueProperty ); #endregion #region ExecuteQueryForMap .NET 2.0 #if dotnet2 /// /// 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 session used to execute the statement /// 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 ExecuteQueryForDictionary(ISqlMapSession session, 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 session used to execute the statement /// 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 hashtable of object containing the rows keyed by keyProperty. /// If a transaction is not in progress, or the database throws an exception. IDictionary ExecuteQueryForDictionary(ISqlMapSession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate); #endif #endregion #region ExecuteUpdate /// /// Execute an update statement. Also used for delete statement. /// Return the number of row effected. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// The number of row effected. int ExecuteUpdate(ISqlMapSession session, object parameterObject ); #endregion #region ExecuteInsert /// /// Execute an insert statement. Fill the parameter object with /// the ouput parameters if any, also could return the insert generated key /// /// The session /// The parameter object used to fill the statement. /// Can return the insert generated key. object ExecuteInsert(ISqlMapSession session, object parameterObject ); #endregion #region ExecuteQueryForList /// /// Executes the SQL and and fill a strongly typed collection. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// A strongly typed collection of result objects. void ExecuteQueryForList(ISqlMapSession session, object parameterObject, IList resultObject ); /// /// Executes the SQL and retuns a subset of the rows selected. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// The number of rows to skip over. /// The maximum number of rows to return. /// A List of result objects. IList ExecuteQueryForList( ISqlMapSession session, object parameterObject, int skipResults, int maxResults ); /// /// Executes the SQL and retuns all rows selected. This is exactly the same as /// calling ExecuteQueryForList(session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS). /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// A List of result objects. IList ExecuteQueryForList( ISqlMapSession session, object parameterObject ); #endregion #region ExecuteQueryForList .NET 2.0 #if dotnet2 /// /// Executes the SQL and and fill a strongly typed collection. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// A strongly typed collection of result objects. void ExecuteQueryForList(ISqlMapSession session, object parameterObject, IList resultObject); /// /// Executes the SQL and retuns a subset of the rows selected. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// The number of rows to skip over. /// The maximum number of rows to return. /// A List of result objects. IList ExecuteQueryForList(ISqlMapSession session, object parameterObject, int skipResults, int maxResults); /// /// Executes the SQL and retuns all rows selected. This is exactly the same as /// calling ExecuteQueryForList(session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS). /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// A List of result objects. IList ExecuteQueryForList(ISqlMapSession session, object parameterObject); #endif #endregion #region ExecuteForObject /// /// Executes an SQL statement that returns a single row as an Object. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// The object object ExecuteQueryForObject( ISqlMapSession session, object parameterObject ); /// /// Executes an SQL statement that returns a single row as an Object of the type of /// the resultObject passed in as a parameter. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// The result object. /// The object object ExecuteQueryForObject( ISqlMapSession session, object parameterObject, object resultObject ); #endregion #region ExecuteForObject .NET 2.0 #if dotnet2 /// /// Executes an SQL statement that returns a single row as an Object. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// The object T ExecuteQueryForObject(ISqlMapSession session, object parameterObject); /// /// Executes an SQL statement that returns a single row as an Object of the type of /// the resultObject passed in as a parameter. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// The result object. /// The object T ExecuteQueryForObject(ISqlMapSession session, object parameterObject, T resultObject); #endif #endregion #region Delegate /// /// Runs a query with a custom object that gets a chance /// to deal with each row as it is processed. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// param> /// IList ExecuteQueryForRowDelegate( ISqlMapSession session, object parameterObject, RowDelegate rowDelegate ); /// /// Runs a query with a custom object that gets a chance /// to deal with each row as it is processed. /// /// The session used to execute the statement /// 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 hashtable of object containing the rows keyed by keyProperty. /// If a transaction is not in progress, or the database throws an exception. IDictionary ExecuteQueryForMapWithRowDelegate( ISqlMapSession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate ); #endregion #region ExecuteQueryForRowDelegate .NET 2.0 #if dotnet2 /// /// Runs a query with a custom object that gets a chance /// to deal with each row as it is processed. /// /// The session used to execute the statement. /// The object used to set the parameters in the SQL. /// param> /// IList ExecuteQueryForRowDelegate(ISqlMapSession session, object parameterObject, RowDelegate rowDelegate); #endif #endregion } }