#region Apache Notice
/*****************************************************************************
* $Header: $
* $Revision: 476843 $
* $Date$
*
* 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
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using Apache.Ibatis.DataMapper.Data;
using Apache.Ibatis.DataMapper.Model;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.Session;
#endregion
namespace Apache.Ibatis.DataMapper.MappedStatements
{
///
/// Summary description for IMappedStatement.
///
public interface IMappedStatement : IMappedStatementEvents
{
#region Event
///
/// Event launch on exceute query
///
event EventHandler Executed;
#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 used by this MappedStatement
///
/// The model store.
IModelStore ModelStore { 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( ISession session, object parameterObject, string keyProperty, string valueProperty );
#endregion
#region ExecuteQueryForMap .NET 2.0
///
/// 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(ISession 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(ISession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate);
#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(ISession 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(ISession 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(ISession session, object parameterObject, IList resultObject );
///
/// Executes the SQL and retuns all rows selected.
///
/// The session used to execute the statement.
/// The object used to set the parameters in the SQL.
/// A List of result objects.
IList ExecuteQueryForList( ISession session, object parameterObject );
#endregion
#region ExecuteQueryForList .NET 2.0
///
/// 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(ISession session, object parameterObject, IList resultObject);
///
/// Executes the SQL and retuns all rows selected.
///
/// The session used to execute the statement.
/// The object used to set the parameters in the SQL.
/// A List of result objects.
IList ExecuteQueryForList(ISession session, object parameterObject);
#endregion
#region ExecuteForObject
///
/// 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( ISession session, object parameterObject, object resultObject );
#endregion
#region ExecuteForObject .NET 2.0
///
/// 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(ISession session, object parameterObject, T resultObject);
#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( ISession 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( ISession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate );
#endregion
#region ExecuteQueryForRowDelegate .NET 2.0
///
/// 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(ISession session, object parameterObject, RowDelegate rowDelegate);
#endregion
#region ExecuteQueryForDataTable
///
/// Executes an SQL statement that returns DataTable.
///
/// The session used to execute the statement.
/// The object used to set the parameters in the SQL.
/// The object
DataTable ExecuteQueryForDataTable(ISession session, object parameterObject);
#endregion
}
}