You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2006/10/30 20:09:14 UTC

svn commit: r469233 [3/4] - in /ibatis/trunk/cs/mapper: IBatisNet.DataMapper.Test/ IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ IBatisNet.DataMapper.Test/bin/Debug/ IBatisNet.DataMapper/ IBatisNet.DataMap...

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Mon Oct 30 11:09:11 2006
@@ -32,231 +32,215 @@
 using System.Collections.Generic;
 #endif
 using System.Data;
-using System.Reflection;
 using System.Text;
 
 using IBatisNet.Common;
-using IBatisNet.Common.Logging;
 using IBatisNet.Common.Utilities.Objects;
 
 
 using IBatisNet.DataMapper.Commands;
 using IBatisNet.DataMapper.Configuration.ParameterMapping;
-using IBatisNet.DataMapper.Configuration.ResultMapping;
 using IBatisNet.DataMapper.Configuration.Statements;
 using IBatisNet.DataMapper.MappedStatements.ResultStrategy;
 using IBatisNet.DataMapper.Scope;
 using IBatisNet.DataMapper.MappedStatements.PostSelectStrategy;
 using IBatisNet.DataMapper.Exceptions;
 using IBatisNet.DataMapper.TypeHandlers;
-using IBatisNet.DataMapper.DataExchange;
-
 
 #endregion
 
 namespace IBatisNet.DataMapper.MappedStatements
 {
 
-	/// <summary>
-	/// Summary description for MappedStatement.
-	/// </summary>
-	public class MappedStatement : IMappedStatement
-	{
-		/// <summary>
-		/// Event launch on exceute query
-		/// </summary>
-		public event ExecuteEventHandler Execute;
-
-		#region Fields 
-
-		// Magic number used to set the the maximum number of rows returned to 'all'. 
-		internal const int NO_MAXIMUM_RESULTS = -1;
-		// Magic number used to set the the number of rows skipped to 'none'. 
-		internal const int NO_SKIPPED_RESULTS = -1;
+    /// <summary>
+    /// Summary description for MappedStatement.
+    /// </summary>
+    public class MappedStatement : IMappedStatement
+    {
+        /// <summary>
+        /// Event launch on exceute query
+        /// </summary>
+        public event ExecuteEventHandler Execute;
+
+        #region Fields
 
-		private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
-		private IStatement _statement = null;
+        // Magic number used to set the the maximum number of rows returned to 'all'. 
+        internal const int NO_MAXIMUM_RESULTS = -1;
+        // Magic number used to set the the number of rows skipped to 'none'. 
+        internal const int NO_SKIPPED_RESULTS = -1;
+
+        private IStatement _statement = null;
         private ISqlMapper _sqlMap = null;
-		private IPreparedCommand _preparedCommand = null;
-		private IResultStrategy _resultStrategy = null;
-		private ReaderAutoMapper _readerAutoMapper = null;
-		#endregion
-
-		#region Properties
-
-		/// <summary>
-		/// Gets or sets the <see cref="ReaderAutoMapper"/>.
-		/// </summary>
-		/// <value>The <see cref="ReaderAutoMapper"/>.</value>
-		public ReaderAutoMapper ReaderAutoMapper
-		{
-			set {  _readerAutoMapper = value; }
-			get { return _readerAutoMapper; }
-		}
-
-		/// <summary>
-		/// The IPreparedCommand to use
-		/// </summary>
-		public IPreparedCommand PreparedCommand
-		{
-			get { return _preparedCommand; }
-		}
-
-		/// <summary>
-		/// Name used to identify the MappedStatement amongst the others.
-		/// This the name of the SQL statement by default.
-		/// </summary>
-		public string Id
-		{
-			get { return _statement.Id; }
-		}
-
-		/// <summary>
-		/// The SQL statment used by this MappedStatement
-		/// </summary>
-		public IStatement Statement
-		{
-			get { return _statement; }
-		}
-
-		/// <summary>
-		/// The SqlMap used by this MappedStatement
-		/// </summary>
+        private IPreparedCommand _preparedCommand = null;
+        private IResultStrategy _resultStrategy = null;
+        #endregion
+
+        #region Properties
+
+
+        /// <summary>
+        /// The IPreparedCommand to use
+        /// </summary>
+        public IPreparedCommand PreparedCommand
+        {
+            get { return _preparedCommand; }
+        }
+
+        /// <summary>
+        /// Name used to identify the MappedStatement amongst the others.
+        /// This the name of the SQL statement by default.
+        /// </summary>
+        public string Id
+        {
+            get { return _statement.Id; }
+        }
+
+        /// <summary>
+        /// The SQL statment used by this MappedStatement
+        /// </summary>
+        public IStatement Statement
+        {
+            get { return _statement; }
+        }
+
+        /// <summary>
+        /// The SqlMap used by this MappedStatement
+        /// </summary>
         public ISqlMapper SqlMap
-		{
-			get { return _sqlMap; }
-		}
-		#endregion
-
-		#region Constructor (s) / Destructor
-		/// <summary>
-		/// Constructor
-		/// </summary>
-		/// <param name="sqlMap">An SqlMap</param>
-		/// <param name="statement">An SQL statement</param>
-		internal MappedStatement( ISqlMapper sqlMap, IStatement statement )
-		{
-			_sqlMap = sqlMap;
-			_statement = statement;
-			_preparedCommand = PreparedCommandFactory.GetPreparedCommand( false );
-			_resultStrategy = ResultStrategyFactory.Get(_statement);
-		}
-		#endregion
-
-		#region Methods
-	
-		/// <summary>
-		/// Retrieve the output parameter and map them on the result object.
-		/// This routine is only use is you specified a ParameterMap and some output attribute
-		/// or if you use a store procedure with output parameter...
-		/// </summary>
-		/// <param name="request"></param>
-		/// <param name="session">The current session.</param>
-		/// <param name="result">The result object.</param>
-		/// <param name="command">The command sql.</param>
-		private void RetrieveOutputParameters(RequestScope request, IDalSession session, IDbCommand command, object result)
-		{
-			if (request.ParameterMap != null)
-			{
-				int count = request.ParameterMap.PropertiesList.Count;
-				for(int i=0; i<count; i++)
-				{
-					ParameterProperty  mapping = request.ParameterMap.GetProperty(i);
-					if (mapping.Direction == ParameterDirection.Output || 
-						mapping.Direction == ParameterDirection.InputOutput) 
-					{
-						string parameterName = string.Empty;
-						if (session.DataSource.DbProvider.UseParameterPrefixInParameter == false)
-						{
-							parameterName =  mapping.ColumnName;
-						}
-						else
-						{
-							parameterName = session.DataSource.DbProvider.ParameterPrefix + 
-								mapping.ColumnName;
-						}
-						
-						if (mapping.TypeHandler == null) // Find the TypeHandler
-						{
-							lock(mapping) 
-							{
-								if (mapping.TypeHandler == null)
-								{
-									Type propertyType =ObjectProbe.GetMemberTypeForGetter(result,mapping.PropertyName);
-
-									mapping.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(propertyType);
-								}
-							}					
-						}
-						
-						object dataBaseValue = mapping.TypeHandler.GetDataBaseValue( ((IDataParameter)command.Parameters[parameterName]).Value, result.GetType() );
-						request.IsRowDataFound = request.IsRowDataFound || (dataBaseValue != null);
-
-						request.ParameterMap.SetOutputParameter(ref result, mapping, dataBaseValue);
-					}
-				}
-			}
-		}
-
-		
-		#region ExecuteForObject
-
-		/// <summary>
-		/// Executes an SQL statement that returns a single row as an Object.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <returns>The object</returns>
-		public virtual object ExecuteQueryForObject( IDalSession session, object parameterObject )
-		{
-			return ExecuteQueryForObject(session, parameterObject, null);
-		}
-
-
-		/// <summary>
-		/// Executes an SQL statement that returns a single row as an Object of the type of
-		/// the resultObject passed in as a parameter.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <param name="resultObject">The result object.</param>
-		/// <returns>The object</returns>
-		public virtual object ExecuteQueryForObject(IDalSession session, object parameterObject, object resultObject )
-		{
-			object obj = null;
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			_preparedCommand.Create( request, session, this.Statement, parameterObject );
-
-			obj = RunQueryForObject(request, session, parameterObject, resultObject);
-			
-			return obj;
-		}
-
-		
-		/// <summary>
-		/// Executes an SQL statement that returns a single row as an Object of the type of
-		/// the resultObject passed in as a parameter.
-		/// </summary>
-		/// <param name="request">The request scope.</param>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <param name="resultObject">The result object.</param>
-		/// <returns>The object</returns>
-		internal object RunQueryForObject(RequestScope request, IDalSession session, object parameterObject, object resultObject )
-		{
-			object result = resultObject;
-			
-			using ( IDbCommand command = request.IDbCommand )
-			{
+        {
+            get { return _sqlMap; }
+        }
+        #endregion
+
+        #region Constructor (s) / Destructor
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="sqlMap">An SqlMap</param>
+        /// <param name="statement">An SQL statement</param>
+        internal MappedStatement(ISqlMapper sqlMap, IStatement statement)
+        {
+            _sqlMap = sqlMap;
+            _statement = statement;
+            _preparedCommand = PreparedCommandFactory.GetPreparedCommand(false);
+            _resultStrategy = ResultStrategyFactory.Get(_statement);
+        }
+        #endregion
+
+        #region Methods
+
+        /// <summary>
+        /// Retrieve the output parameter and map them on the result object.
+        /// This routine is only use is you specified a ParameterMap and some output attribute
+        /// or if you use a store procedure with output parameter...
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="session">The current session.</param>
+        /// <param name="result">The result object.</param>
+        /// <param name="command">The command sql.</param>
+        private void RetrieveOutputParameters(RequestScope request, IDalSession session, IDbCommand command, object result)
+        {
+            if (request.ParameterMap != null)
+            {
+                int count = request.ParameterMap.PropertiesList.Count;
+                for (int i = 0; i < count; i++)
+                {
+                    ParameterProperty mapping = request.ParameterMap.GetProperty(i);
+                    if (mapping.Direction == ParameterDirection.Output ||
+                        mapping.Direction == ParameterDirection.InputOutput)
+                    {
+                        string parameterName = string.Empty;
+                        if (session.DataSource.DbProvider.UseParameterPrefixInParameter == false)
+                        {
+                            parameterName = mapping.ColumnName;
+                        }
+                        else
+                        {
+                            parameterName = session.DataSource.DbProvider.ParameterPrefix +
+                                mapping.ColumnName;
+                        }
+
+                        if (mapping.TypeHandler == null) // Find the TypeHandler
+                        {
+                            lock (mapping)
+                            {
+                                if (mapping.TypeHandler == null)
+                                {
+                                    Type propertyType = ObjectProbe.GetMemberTypeForGetter(result, mapping.PropertyName);
+
+                                    mapping.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(propertyType);
+                                }
+                            }
+                        }
+
+                        object dataBaseValue = mapping.TypeHandler.GetDataBaseValue(((IDataParameter)command.Parameters[parameterName]).Value, result.GetType());
+                        request.IsRowDataFound = request.IsRowDataFound || (dataBaseValue != null);
+
+                        request.ParameterMap.SetOutputParameter(ref result, mapping, dataBaseValue);
+                    }
+                }
+            }
+        }
+
+
+        #region ExecuteForObject
+
+        /// <summary>
+        /// Executes an SQL statement that returns a single row as an Object.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <returns>The object</returns>
+        public virtual object ExecuteQueryForObject(IDalSession session, object parameterObject)
+        {
+            return ExecuteQueryForObject(session, parameterObject, null);
+        }
+
+
+        /// <summary>
+        /// Executes an SQL statement that returns a single row as an Object of the type of
+        /// the resultObject passed in as a parameter.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="resultObject">The result object.</param>
+        /// <returns>The object</returns>
+        public virtual object ExecuteQueryForObject(IDalSession session, object parameterObject, object resultObject)
+        {
+            object obj = null;
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            obj = RunQueryForObject(request, session, parameterObject, resultObject);
+
+            return obj;
+        }
+
+
+        /// <summary>
+        /// Executes an SQL statement that returns a single row as an Object of the type of
+        /// the resultObject passed in as a parameter.
+        /// </summary>
+        /// <param name="request">The request scope.</param>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="resultObject">The result object.</param>
+        /// <returns>The object</returns>
+        internal object RunQueryForObject(RequestScope request, IDalSession session, object parameterObject, object resultObject)
+        {
+            object result = resultObject;
+
+            using (IDbCommand command = request.IDbCommand)
+            {
                 IDataReader reader = command.ExecuteReader();
-			    try
-			    {
-					if ( reader.Read() )
-					{
-                        result = _resultStrategy.Process(request, ref reader, resultObject);		
-					}			        
-			    }
+                try
+                {
+                    while (reader.Read())
+                    {
+                        result = _resultStrategy.Process(request, ref reader, resultObject);
+                    }
+                }
                 catch
                 {
                     throw;
@@ -265,26 +249,26 @@
                 {
                     reader.Close();
                     reader.Dispose();
-                }	    
+                }
 
-				ExecutePostSelect(request);
+                ExecutePostSelect(request);
 
-				#region remark
-				// If you are using the OleDb data provider (as you are), you need to close the
-				// DataReader before output parameters are visible.
-				#endregion
+                #region remark
+                // If you are using the OleDb data provider (as you are), you need to close the
+                // DataReader before output parameters are visible.
+                #endregion
 
-				RetrieveOutputParameters(request, session, command, parameterObject);
-			}
+                RetrieveOutputParameters(request, session, command, parameterObject);
+            }
 
-			RaiseExecuteEvent();
+            RaiseExecuteEvent();
 
-			return result;
-		}
+            return result;
+        }
 
-		#endregion
+        #endregion
 
-		#region ExecuteForObject .NET 2.0
+        #region ExecuteForObject .NET 2.0
 #if dotnet2
 
         /// <summary>
@@ -314,7 +298,7 @@
 
             _preparedCommand.Create(request, session, this.Statement, parameterObject);
 
-            obj = (T)RunQueryForObject(request, session, parameterObject, resultObject);
+            obj = RunQueryForObject<T>(request, session, parameterObject, resultObject);
 
             return obj;
         }
@@ -336,13 +320,13 @@
             using (IDbCommand command = request.IDbCommand)
             {
                 IDataReader reader = command.ExecuteReader();
-                try 
+                try
                 {
-                    if (reader.Read())
+                    while (reader.Read())
                     {
                         result = (T)_resultStrategy.Process(request, ref reader, resultObject);
                     }
-			    }
+                }
                 catch
                 {
                     throw;
@@ -353,12 +337,12 @@
                     reader.Dispose();
                 }
 
-                ExecutePostSelect( request );
+                ExecutePostSelect(request);
 
-		#region remark
-                // If you are using the OleDb data provider (as you are), you need to close the
+                #region remark
+                // If you are using the OleDb data provider, you need to close the
                 // DataReader before output parameters are visible.
-		#endregion
+                #endregion
 
                 RetrieveOutputParameters(request, session, command, parameterObject);
             }
@@ -368,200 +352,209 @@
             return result;
         }
 #endif
-		#endregion
+        #endregion
 
-		#region ExecuteQueryForList
+        #region ExecuteQueryForList
 
-		/// <summary>
-		/// Runs a query with a custom object that gets a chance 
-		/// to deal with each row as it is processed.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <param name="rowDelegate"></param>
-		public virtual IList ExecuteQueryForRowDelegate( IDalSession session, object parameterObject, RowDelegate rowDelegate )
-		{
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			_preparedCommand.Create( request, session, this.Statement, parameterObject );
-
-			if (rowDelegate == null) 
-			{
-				throw new DataMapperException("A null RowDelegate was passed to QueryForRowDelegate.");
-			}
-			
-			return RunQueryForList(request, session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS, rowDelegate);
-		}
-
-		/// <summary>
-		/// Runs a query with a custom object that gets a chance 
-		/// to deal with each row as it is processed.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL. </param>
-		/// <param name="keyProperty">The property of the result object to be used as the key. </param>
-		/// <param name="valueProperty">The property of the result object to be used as the value (or null)</param>
-		/// <param name="rowDelegate"></param>
-		/// <returns>A hashtable of object containing the rows keyed by keyProperty.</returns>
-		///<exception cref="DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
-		public virtual IDictionary ExecuteQueryForMapWithRowDelegate( IDalSession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate )
-		{
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			if (rowDelegate == null) 
-			{
-				throw new DataMapperException("A null DictionaryRowDelegate was passed to QueryForMapWithRowDelegate.");
-			}
-			
-			_preparedCommand.Create(request, session, this.Statement, parameterObject);
-
-			return RunQueryForMap(request, session, parameterObject, keyProperty, valueProperty, rowDelegate);
-		}
-
-		
-		/// <summary>
-		/// Executes the SQL and retuns all rows selected. This is exactly the same as
-		/// calling ExecuteQueryForList(session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS).
-		/// </summary>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <returns>A List of result objects.</returns>
-		public virtual IList ExecuteQueryForList( IDalSession session, object parameterObject )
-		{
-			return ExecuteQueryForList( session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS);
-		}
-
-
-		/// <summary>
-		/// Executes the SQL and retuns a subset of the rows selected.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <param name="skipResults">The number of rows to skip over.</param>
-		/// <param name="maxResults">The maximum number of rows to return.</param>
-		/// <returns>A List of result objects.</returns>
-		public virtual IList ExecuteQueryForList( IDalSession session, object parameterObject, int skipResults, int maxResults )
-		{
-			IList list = null;
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			_preparedCommand.Create( request, session, this.Statement, parameterObject );
-
-			list = RunQueryForList(request, session, parameterObject, skipResults, maxResults, null);
-			
-			return list;
-		}
-
-		
-		/// <summary>
-		/// Executes the SQL and retuns a List of result objects.
-		/// </summary>
-		/// <param name="request">The request scope.</param>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <param name="skipResults">The number of rows to skip over.</param>
-		/// <param name="maxResults">The maximum number of rows to return.</param>
-		/// <param name="rowDelegate"></param>
-		/// <returns>A List of result objects.</returns>
-		internal IList RunQueryForList(RequestScope request, IDalSession session, object parameterObject, int skipResults, int maxResults,  RowDelegate rowDelegate)
-		{
-			IList list = null;
-
-			using ( IDbCommand command = request.IDbCommand )
-			{
-				if (_statement.ListClass == null)
-				{
-					list = new ArrayList();
-				}
-				else
-				{
-					list = _statement.CreateInstanceOfListClass();
-				}
-                
-			    IDataReader reader = command.ExecuteReader();
-                try		
-                {
-					// skip results
-					for (int i = 0; i < skipResults; i++) 
-					{
-						if (!reader.Read()) 
-						{
-							break;
-						}
-					}
-
-					int n = 0;
-
-					if (rowDelegate == null) 
-					{
-						while ( (maxResults == NO_MAXIMUM_RESULTS || n < maxResults) 
-							&& reader.Read() )
-						{
-                            object obj = _resultStrategy.Process(request, ref reader, null);
-						
-							list.Add( obj );
-							n++;
-						}
-					}
-					else
-					{
-						while ( (maxResults == NO_MAXIMUM_RESULTS || n < maxResults) 
-							&& reader.Read() )
-						{
-                            object obj = _resultStrategy.Process(request, ref reader, null);
+        /// <summary>
+        /// Runs a query with a custom object that gets a chance 
+        /// to deal with each row as it is processed.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="rowDelegate"></param>
+        public virtual IList ExecuteQueryForRowDelegate(IDalSession session, object parameterObject, RowDelegate rowDelegate)
+        {
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            if (rowDelegate == null)
+            {
+                throw new DataMapperException("A null RowDelegate was passed to QueryForRowDelegate.");
+            }
+
+            return RunQueryForList(request, session, parameterObject, null, rowDelegate);
+        }
+
+        /// <summary>
+        /// Runs a query with a custom object that gets a chance 
+        /// to deal with each row as it is processed.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL. </param>
+        /// <param name="keyProperty">The property of the result object to be used as the key. </param>
+        /// <param name="valueProperty">The property of the result object to be used as the value (or null)</param>
+        /// <param name="rowDelegate"></param>
+        /// <returns>A hashtable of object containing the rows keyed by keyProperty.</returns>
+        ///<exception cref="DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
+        public virtual IDictionary ExecuteQueryForMapWithRowDelegate(IDalSession session, object parameterObject, string keyProperty, string valueProperty, DictionaryRowDelegate rowDelegate)
+        {
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            if (rowDelegate == null)
+            {
+                throw new DataMapperException("A null DictionaryRowDelegate was passed to QueryForMapWithRowDelegate.");
+            }
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            return RunQueryForMap(request, session, parameterObject, keyProperty, valueProperty, rowDelegate);
+        }
+
+
+        /// <summary>
+        /// Executes the SQL and retuns all rows selected. This is exactly the same as
+        /// calling ExecuteQueryForList(session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS).
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <returns>A List of result objects.</returns>
+        public virtual IList ExecuteQueryForList(IDalSession session, object parameterObject)
+        {
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            return RunQueryForList(request, session, parameterObject, null, null);
+        }
+
+
+        /// <summary>
+        /// Executes the SQL and retuns a subset of the rows selected.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="skipResults">The number of rows to skip over.</param>
+        /// <param name="maxResults">The maximum number of rows to return.</param>
+        /// <returns>A List of result objects.</returns>
+        public virtual IList ExecuteQueryForList(IDalSession session, object parameterObject, int skipResults, int maxResults)
+        {
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
 
-							rowDelegate(obj, parameterObject, list);
-							n++;
-						}
-					}
-			    }
-			    catch
-			    {
-			        throw;
-			    }
-			    finally
-                {
-			        reader.Close();
-			        reader.Dispose();                    
-                }
-
-				ExecutePostSelect(request);
-
-				RetrieveOutputParameters(request, session, command, parameterObject);
-			}
-
-			return list;
-		}
-		
-		
-		/// <summary>
-		/// Executes the SQL and and fill a strongly typed collection.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <param name="resultObject">A strongly typed collection of result objects.</param>
-		public virtual void ExecuteQueryForList(IDalSession session, object parameterObject, IList resultObject )
-		{
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			_preparedCommand.Create( request, session, this.Statement, parameterObject );
-
-			using ( IDbCommand command = request.IDbCommand )
-			{
-				IDataReader reader = command.ExecuteReader();
-                try 
+            return RunQueryForList(request, session, parameterObject, skipResults, maxResults);
+        }
+
+        /// <summary>
+        /// Runs the query for list.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="skipResults">The number of rows to skip over.</param>
+        /// <param name="maxResults">The maximum number of rows to return.</param>
+        /// <returns>A List of result objects.</returns>
+        internal IList RunQueryForList(RequestScope request, IDalSession session, object parameterObject, int skipResults, int maxResults)
+        {
+            IList list = null;
+            
+            using (IDbCommand command = request.IDbCommand)
+            {
+                if (_statement.ListClass == null)
                 {
-                    do
+                    list = new ArrayList();
+                }
+                else
+                {
+                    list = _statement.CreateInstanceOfListClass();
+                }
+
+                IDataReader reader = command.ExecuteReader();
+
+                try
+                {
+                    // skip results
+                    for (int i = 0; i < skipResults; i++)
                     {
-                        while (reader.Read())
+                        if (!reader.Read())
                         {
-                            object obj = _resultStrategy.Process(request, ref reader, null);
+                            break;
+                        }
+                    }
+
+                    // Get Results
+                    int resultsFetched = 0;
+                    while ((maxResults == NO_MAXIMUM_RESULTS || resultsFetched < maxResults)
+                        && reader.Read())
+                    {
+                        object obj = _resultStrategy.Process(request, ref reader, null);
+
+                        list.Add(obj);
+                        resultsFetched++;
+                    }
+                }
+                catch
+                {
+                    throw;
+                }
+                finally
+                {
+                    reader.Close();
+                    reader.Dispose();
+                }
+
+                ExecutePostSelect(request);
+
+                RetrieveOutputParameters(request, session, command, parameterObject);
+            }
+
+            return list;
+        }
 
-                            resultObject.Add(obj);
+        /// <summary>
+        /// Executes the SQL and retuns a List of result objects.
+        /// </summary>
+        /// <param name="request">The request scope.</param>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="resultObject">A strongly typed collection of result objects.</param>
+        /// <param name="rowDelegate"></param>
+        /// <returns>A List of result objects.</returns>
+        internal IList RunQueryForList(RequestScope request, IDalSession session, object parameterObject, IList resultObject, RowDelegate rowDelegate)
+        {
+            IList list = resultObject;
+
+            using (IDbCommand command = request.IDbCommand)
+            {
+                if (resultObject==null)
+                {
+                    if (_statement.ListClass == null)
+                    {
+                        list = new ArrayList();
+                    }
+                    else
+                    {
+                        list = _statement.CreateInstanceOfListClass();
+                    }
+                }
+
+                IDataReader reader = command.ExecuteReader();
+
+                try
+                { 
+                    do
+                    {
+                        if (rowDelegate == null)
+                        {
+                            while (reader.Read())
+                            {
+                                object obj = _resultStrategy.Process(request, ref reader, null);
+                                list.Add(obj);
+                            }
+                        }
+                        else
+                        {
+                            while (reader.Read())
+                            {
+                                object obj = _resultStrategy.Process(request, ref reader, null);
+                                rowDelegate(obj, parameterObject, list);
+                            }
                         }
                     }
                     while (reader.NextResult());
-			    }
+                }
                 catch
                 {
                     throw;
@@ -572,16 +565,33 @@
                     reader.Dispose();
                 }
 
-				ExecutePostSelect(request);
+                ExecutePostSelect(request);
+                RetrieveOutputParameters(request, session, command, parameterObject);
+            }
+
+            return list;
+        }
+
+
+        /// <summary>
+        /// Executes the SQL and and fill a strongly typed collection.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="resultObject">A strongly typed collection of result objects.</param>
+        public virtual void ExecuteQueryForList(IDalSession session, object parameterObject, IList resultObject)
+        {
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            RunQueryForList(request, session, parameterObject, resultObject, null);
+        }
 
-				RetrieveOutputParameters(request, session, command, parameterObject);
-			}
-		}
 
-		
-		#endregion
+        #endregion
 
-		#region ExecuteQueryForList .NET 2.0
+        #region ExecuteQueryForList .NET 2.0
 #if dotnet2
 
         /// <summary>
@@ -601,8 +611,7 @@
             {
                 throw new DataMapperException("A null RowDelegate was passed to QueryForRowDelegate.");
             }
-
-            return RunQueryForList<T>(request, session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS, rowDelegate);
+            return RunQueryForList<T>(request, session, parameterObject, null, rowDelegate);
         }
 
 
@@ -615,7 +624,11 @@
         /// <returns>A List of result objects.</returns>
         public virtual IList<T> ExecuteQueryForList<T>(IDalSession session, object parameterObject)
         {
-            return ExecuteQueryForList<T>(session, parameterObject, NO_SKIPPED_RESULTS, NO_MAXIMUM_RESULTS);
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            return RunQueryForList<T>(request, session, parameterObject, null, null);
         }
 
 
@@ -629,14 +642,11 @@
         /// <returns>A List of result objects.</returns>
         public virtual IList<T> ExecuteQueryForList<T>(IDalSession session, object parameterObject, int skipResults, int maxResults)
         {
-            IList<T> list = null;
             RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
 
             _preparedCommand.Create(request, session, this.Statement, parameterObject);
 
-            list = RunQueryForList<T>(request, session, parameterObject, skipResults, maxResults, null);
-
-            return list;
+            return RunQueryForList<T>(request, session, parameterObject, skipResults, maxResults);
         }
 
 
@@ -648,9 +658,8 @@
         /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
         /// <param name="skipResults">The number of rows to skip over.</param>
         /// <param name="maxResults">The maximum number of rows to return.</param>
-        /// <param name="rowDelegate"></param>
         /// <returns>A List of result objects.</returns>
-        internal IList<T> RunQueryForList<T>(RequestScope request, IDalSession session, object parameterObject, int skipResults, int maxResults, RowDelegate<T> rowDelegate)
+        internal IList<T> RunQueryForList<T>(RequestScope request, IDalSession session, object parameterObject, int skipResults, int maxResults)
         {
             IList<T> list = null;
 
@@ -664,9 +673,9 @@
                 {
                     list = _statement.CreateInstanceOfGenericListClass<T>();
                 }
-                
+
                 IDataReader reader = command.ExecuteReader();
-                try 
+                try
                 {
                     // skip results
                     for (int i = 0; i < skipResults; i++)
@@ -677,31 +686,16 @@
                         }
                     }
 
-                    int n = 0;
-
-                    if (rowDelegate == null)
+                    int resultsFetched = 0;
+                    while ((maxResults == NO_MAXIMUM_RESULTS || resultsFetched < maxResults)
+                        && reader.Read())
                     {
-                        while ((maxResults == NO_MAXIMUM_RESULTS || n < maxResults)
-                            && reader.Read())
-                        {
-                            T obj = (T)_resultStrategy.Process(request, ref reader, null);
-
-                            list.Add(obj);
-                            n++;
-                        }
-                    }
-                    else
-                    {
-                        while ((maxResults == NO_MAXIMUM_RESULTS || n < maxResults)
-                            && reader.Read())
-                        {
-                            T obj = (T)_resultStrategy.Process(request, ref reader, null);
+                        T obj = (T)_resultStrategy.Process(request, ref reader, null);
 
-                            rowDelegate(obj, parameterObject, list);
-                            n++;
-                        }
+                        list.Add(obj);
+                        resultsFetched++;
                     }
-			    }
+                }
                 catch
                 {
                     throw;
@@ -712,7 +706,7 @@
                     reader.Dispose();
                 }
 
-                ExecutePostSelect( request );
+                ExecutePostSelect(request);
 
                 RetrieveOutputParameters(request, session, command, parameterObject);
             }
@@ -720,31 +714,58 @@
             return list;
         }
 
-
         /// <summary>
-        /// Executes the SQL and and fill a strongly typed collection.
+        /// Executes the SQL and retuns a List of result objects.
         /// </summary>
+        /// <param name="request">The request scope.</param>
         /// <param name="session">The session used to execute the statement.</param>
         /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-        /// <param name="resultObject">A strongly typed collection of result objects.</param>
-        public virtual void ExecuteQueryForList<T>(IDalSession session, object parameterObject, IList<T> resultObject)
+        /// <param name="resultObject">The result object</param>
+        /// <param name="rowDelegate"></param>
+        /// <returns>A List of result objects.</returns>
+        internal IList<T> RunQueryForList<T>(RequestScope request, IDalSession session, 
+                                             object parameterObject, IList<T> resultObject, RowDelegate<T> rowDelegate)
         {
-            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+            IList<T> list = resultObject;
 
             using (IDbCommand command = request.IDbCommand)
             {
-                IDataReader reader = command.ExecuteReader();
-                try 
+                if (resultObject == null)
                 {
-                    while (reader.Read())
+                    if (_statement.ListClass == null)
                     {
-                        T obj = (T)_resultStrategy.Process(request, ref reader, null);
+                        list = new List<T>();
+                    }
+                    else
+                    {
+                        list = _statement.CreateInstanceOfGenericListClass<T>();
+                    }
+                }
 
-                        resultObject.Add(obj);
+                IDataReader reader = command.ExecuteReader();
+                try
+                {
+                    do
+                    {
+                        if (rowDelegate == null)
+                        {
+                            while (reader.Read())
+                            {
+                                T obj = (T)_resultStrategy.Process(request, ref reader, null);
+                                list.Add(obj);
+                            }
+                        }
+                        else
+                        {
+                            while (reader.Read())
+                            {
+                                T obj = (T)_resultStrategy.Process(request, ref reader, null);
+                                rowDelegate(obj, parameterObject, list);
+                            }
+                        }
                     }
- 			    }
+                    while (reader.NextResult());
+                }
                 catch
                 {
                     throw;
@@ -755,210 +776,227 @@
                     reader.Dispose();
                 }
 
-                ExecutePostSelect( request );
-
+                ExecutePostSelect(request);
                 RetrieveOutputParameters(request, session, command, parameterObject);
             }
+
+            return list;
+        }
+
+        /// <summary>
+        /// Executes the SQL and and fill a strongly typed collection.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="resultObject">A strongly typed collection of result objects.</param>
+        public virtual void ExecuteQueryForList<T>(IDalSession session, object parameterObject, IList<T> resultObject)
+        {
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            RunQueryForList<T>(request, session, parameterObject, resultObject, null);
         }
 
 #endif
-		#endregion
+        #endregion
 
-		#region ExecuteUpdate, ExecuteInsert
+        #region ExecuteUpdate, ExecuteInsert
 
-		/// <summary>
-		/// Execute an update statement. Also used for delete statement.
-		/// Return the number of row effected.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement.</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <returns>The number of row effected.</returns>
-		public virtual int ExecuteUpdate(IDalSession session, object parameterObject )
-		{
-			int rows = 0; // the number of rows affected
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			_preparedCommand.Create( request, session, this.Statement, parameterObject );
-	
-			using ( IDbCommand command = request.IDbCommand )
-			{
-				rows = command.ExecuteNonQuery();
-
-				ExecutePostSelect(request);
-
-				RetrieveOutputParameters(request, session, command, parameterObject);
-			}
-
-			RaiseExecuteEvent();
-
-			return rows;
-		}
-
-		
-		/// <summary>
-		/// Execute an insert statement. Fill the parameter object with 
-		/// the ouput parameters if any, also could return the insert generated key
-		/// </summary>
-		/// <param name="session">The session</param>
-		/// <param name="parameterObject">The parameter object used to fill the statement.</param>
-		/// <returns>Can return the insert generated key.</returns>
-		public virtual object ExecuteInsert(IDalSession session, object parameterObject )
-		{
-			object generatedKey = null;
-			SelectKey selectKeyStatement = null;
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			if (_statement is Insert)
-			{
-				selectKeyStatement = ((Insert)_statement).SelectKey;
-			}
-
-			if (selectKeyStatement != null && !selectKeyStatement.isAfter)
-			{
-				IMappedStatement mappedStatement = _sqlMap.GetMappedStatement( selectKeyStatement.Id );
-				generatedKey = mappedStatement.ExecuteQueryForObject(session, parameterObject);
+        /// <summary>
+        /// Execute an update statement. Also used for delete statement.
+        /// Return the number of row effected.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement.</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <returns>The number of row effected.</returns>
+        public virtual int ExecuteUpdate(IDalSession session, object parameterObject)
+        {
+            int rows = 0; // the number of rows affected
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
 
-				ObjectProbe.SetMemberValue(parameterObject, selectKeyStatement.PropertyName, generatedKey, 
-					request.DataExchangeFactory.ObjectFactory,
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            using (IDbCommand command = request.IDbCommand)
+            {
+                rows = command.ExecuteNonQuery();
+
+                ExecutePostSelect(request);
+
+                RetrieveOutputParameters(request, session, command, parameterObject);
+            }
+
+            RaiseExecuteEvent();
+
+            return rows;
+        }
+
+
+        /// <summary>
+        /// Execute an insert statement. Fill the parameter object with 
+        /// the ouput parameters if any, also could return the insert generated key
+        /// </summary>
+        /// <param name="session">The session</param>
+        /// <param name="parameterObject">The parameter object used to fill the statement.</param>
+        /// <returns>Can return the insert generated key.</returns>
+        public virtual object ExecuteInsert(IDalSession session, object parameterObject)
+        {
+            object generatedKey = null;
+            SelectKey selectKeyStatement = null;
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
+
+            if (_statement is Insert)
+            {
+                selectKeyStatement = ((Insert)_statement).SelectKey;
+            }
+
+            if (selectKeyStatement != null && !selectKeyStatement.isAfter)
+            {
+                IMappedStatement mappedStatement = _sqlMap.GetMappedStatement(selectKeyStatement.Id);
+                generatedKey = mappedStatement.ExecuteQueryForObject(session, parameterObject);
+
+                ObjectProbe.SetMemberValue(parameterObject, selectKeyStatement.PropertyName, generatedKey,
+                    request.DataExchangeFactory.ObjectFactory,
                     request.DataExchangeFactory.AccessorFactory);
-			}
+            }
 
-			_preparedCommand.Create( request, session, this.Statement, parameterObject );
-			using ( IDbCommand command = request.IDbCommand)
-			{
-				if (_statement is Insert)
-				{
-					command.ExecuteNonQuery();
-				}
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+            using (IDbCommand command = request.IDbCommand)
+            {
+                if (_statement is Insert)
+                {
+                    command.ExecuteNonQuery();
+                }
+                // Retrieve output parameter if the result class is specified
                 else if (_statement is Procedure && (_statement.ResultClass != null) &&
-                        _sqlMap.TypeHandlerFactory.IsSimpleType(_statement.ResultClass) )
+                        _sqlMap.TypeHandlerFactory.IsSimpleType(_statement.ResultClass))
                 {
                     IDataParameter returnValueParameter = command.CreateParameter();
                     returnValueParameter.Direction = ParameterDirection.ReturnValue;
                     command.Parameters.Add(returnValueParameter);
-                    
-                    command.ExecuteNonQuery ( );
+
+                    command.ExecuteNonQuery();
                     generatedKey = returnValueParameter.Value;
 
-                    ITypeHandler typeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler ( _statement.ResultClass );
-                    generatedKey = typeHandler.GetDataBaseValue ( generatedKey, _statement.ResultClass );
-				}
-			    else
-
-				{
-					generatedKey = command.ExecuteScalar();
-					if ( (_statement.ResultClass!=null) && 
-						_sqlMap.TypeHandlerFactory.IsSimpleType(_statement.ResultClass) )
-					{
-						ITypeHandler typeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(_statement.ResultClass);
-						generatedKey = typeHandler.GetDataBaseValue(generatedKey, _statement.ResultClass);
-					}
-				}
-			
-				if (selectKeyStatement != null && selectKeyStatement.isAfter)
-				{
-					IMappedStatement mappedStatement = _sqlMap.GetMappedStatement( selectKeyStatement.Id );
-					generatedKey = mappedStatement.ExecuteQueryForObject(session, parameterObject);
+                    ITypeHandler typeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(_statement.ResultClass);
+                    generatedKey = typeHandler.GetDataBaseValue(generatedKey, _statement.ResultClass);
+                }
+                else
+                {
+                    generatedKey = command.ExecuteScalar();
+                    if ((_statement.ResultClass != null) &&
+                        _sqlMap.TypeHandlerFactory.IsSimpleType(_statement.ResultClass))
+                    {
+                        ITypeHandler typeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(_statement.ResultClass);
+                        generatedKey = typeHandler.GetDataBaseValue(generatedKey, _statement.ResultClass);
+                    }
+                }
+
+                if (selectKeyStatement != null && selectKeyStatement.isAfter)
+                {
+                    IMappedStatement mappedStatement = _sqlMap.GetMappedStatement(selectKeyStatement.Id);
+                    generatedKey = mappedStatement.ExecuteQueryForObject(session, parameterObject);
 
-					ObjectProbe.SetMemberValue(parameterObject, selectKeyStatement.PropertyName, generatedKey,
+                    ObjectProbe.SetMemberValue(parameterObject, selectKeyStatement.PropertyName, generatedKey,
                         request.DataExchangeFactory.ObjectFactory,
                         request.DataExchangeFactory.AccessorFactory);
-				}
+                }
+
+                ExecutePostSelect(request);
+
+                RetrieveOutputParameters(request, session, command, parameterObject);
+            }
+
+            RaiseExecuteEvent();
+
+            return generatedKey;
+        }
 
-				ExecutePostSelect(request);
+        #endregion
 
-				RetrieveOutputParameters(request, session, command, parameterObject);
-			}
+        #region ExecuteQueryForMap
 
-			RaiseExecuteEvent();
+        /// <summary>
+        /// 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.
+        /// </summary>
+        /// <param name="session">The session used to execute the statement</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL. </param>
+        /// <param name="keyProperty">The property of the result object to be used as the key. </param>
+        /// <param name="valueProperty">The property of the result object to be used as the value (or null)</param>
+        /// <returns>A hashtable of object containing the rows keyed by keyProperty.</returns>
+        ///<exception cref="DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
+        public virtual IDictionary ExecuteQueryForMap(IDalSession session, object parameterObject, string keyProperty, string valueProperty)
+        {
+            IDictionary map = new Hashtable();
+            RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
 
-			return generatedKey;
-		}
-
-		#endregion
-
-		#region ExecuteQueryForMap
-	
-		/// <summary>
-		/// 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.
-		/// </summary>
-		/// <param name="session">The session used to execute the statement</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL. </param>
-		/// <param name="keyProperty">The property of the result object to be used as the key. </param>
-		/// <param name="valueProperty">The property of the result object to be used as the value (or null)</param>
-		/// <returns>A hashtable of object containing the rows keyed by keyProperty.</returns>
-		///<exception cref="DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
-		public virtual IDictionary ExecuteQueryForMap( IDalSession session, object parameterObject, string keyProperty, string valueProperty )
-		{
-			IDictionary map = new Hashtable();
-			RequestScope request = _statement.Sql.GetRequestScope(this, parameterObject, session);
-
-			_preparedCommand.Create(request, session, this.Statement, parameterObject);
-
-			map = RunQueryForMap(request, session, parameterObject, keyProperty, valueProperty, null );
-			
-			return map;
-		}
-
-		
-		/// <summary>
-		/// 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.
-		/// </summary>
-		/// <param name="request">The request scope.</param>
-		/// <param name="session">The session used to execute the statement</param>
-		/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
-		/// <param name="keyProperty">The property of the result object to be used as the key.</param>
-		/// <param name="valueProperty">The property of the result object to be used as the value (or null)</param>
-		/// <param name="rowDelegate"></param>
-		/// <returns>A hashtable of object containing the rows keyed by keyProperty.</returns>
-		///<exception cref="DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
-		internal IDictionary RunQueryForMap( RequestScope request, 
-			IDalSession session, 
-			object parameterObject, 
-			string keyProperty, 
-			string valueProperty, 
-			DictionaryRowDelegate rowDelegate  )
-		{
-			IDictionary map = new Hashtable();
-
-			using (IDbCommand command = request.IDbCommand)
-			{
-			    IDataReader reader = command.ExecuteReader();
-                try 
-                {
-					if (rowDelegate == null)
-					{
-						while (reader.Read() )
-						{
+            _preparedCommand.Create(request, session, this.Statement, parameterObject);
+
+            map = RunQueryForMap(request, session, parameterObject, keyProperty, valueProperty, null);
+
+            return map;
+        }
+
+
+        /// <summary>
+        /// 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.
+        /// </summary>
+        /// <param name="request">The request scope.</param>
+        /// <param name="session">The session used to execute the statement</param>
+        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
+        /// <param name="keyProperty">The property of the result object to be used as the key.</param>
+        /// <param name="valueProperty">The property of the result object to be used as the value (or null)</param>
+        /// <param name="rowDelegate"></param>
+        /// <returns>A hashtable of object containing the rows keyed by keyProperty.</returns>
+        ///<exception cref="DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
+        internal IDictionary RunQueryForMap(RequestScope request,
+            IDalSession session,
+            object parameterObject,
+            string keyProperty,
+            string valueProperty,
+            DictionaryRowDelegate rowDelegate)
+        {
+            IDictionary map = new Hashtable();
+
+            using (IDbCommand command = request.IDbCommand)
+            {
+               IDataReader reader = command.ExecuteReader();
+               try
+                {
+                    
+                   if (rowDelegate == null)
+                    {
+                        while (reader.Read())
+                        {
                             object obj = _resultStrategy.Process(request, ref reader, null);
-							object key = ObjectProbe.GetMemberValue(obj, keyProperty, request.DataExchangeFactory.AccessorFactory);
-							object value = obj;
-							if (valueProperty != null)
-							{
-								value = ObjectProbe.GetMemberValue(obj, valueProperty, request.DataExchangeFactory.AccessorFactory);
-							}
-							map.Add(key, value);
-						}
-					}
-					else
-					{
-						while (reader.Read())
-						{
+                            object key = ObjectProbe.GetMemberValue(obj, keyProperty, request.DataExchangeFactory.AccessorFactory);
+                            object value = obj;
+                            if (valueProperty != null)
+                            {
+                                value = ObjectProbe.GetMemberValue(obj, valueProperty, request.DataExchangeFactory.AccessorFactory);
+                            }
+                            map.Add(key, value);
+                        }
+                    }
+                    else
+                    {
+                        while (reader.Read())
+                        {
                             object obj = _resultStrategy.Process(request, ref reader, null);
-							object key = ObjectProbe.GetMemberValue(obj, keyProperty,request.DataExchangeFactory.AccessorFactory);
-							object value = obj;
-							if (valueProperty != null)
-							{
-								value = ObjectProbe.GetMemberValue(obj, valueProperty, request.DataExchangeFactory.AccessorFactory);
-							}
-							rowDelegate(key, value, parameterObject, map);
+                            object key = ObjectProbe.GetMemberValue(obj, keyProperty, request.DataExchangeFactory.AccessorFactory);
+                            object value = obj;
+                            if (valueProperty != null)
+                            {
+                                value = ObjectProbe.GetMemberValue(obj, valueProperty, request.DataExchangeFactory.AccessorFactory);
+                            }
+                            rowDelegate(key, value, parameterObject, map);
 
-						}
-					}
+                        }
+                    }
                 }
                 catch
                 {
@@ -969,61 +1007,60 @@
                     reader.Close();
                     reader.Dispose();
                 }
-			}
-			return map;
+            }
+            return map;
+
+        }
+
+
+        #endregion
+
+
+        /// <summary>
+        /// Executes the <see cref="PostBindind"/>.
+        /// </summary>
+        /// <param name="request">The current <see cref="RequestScope"/>.</param>
+        private void ExecutePostSelect(RequestScope request)
+        {
+            while (request.QueueSelect.Count > 0)
+            {
+                PostBindind postSelect = request.QueueSelect.Dequeue() as PostBindind;
 
-		}
+                PostSelectStrategyFactory.Get(postSelect.Method).Execute(postSelect, request);
+            }
+        }
+
+
+        /// <summary>
+        /// Raise an event ExecuteEventArgs
+        /// (Used when a query is executed)
+        /// </summary>
+        private void RaiseExecuteEvent()
+        {
+            ExecuteEventArgs e = new ExecuteEventArgs();
+            e.StatementName = _statement.Id;
+            if (Execute != null)
+            {
+                Execute(this, e);
+            }
+        }
 
-		
-		#endregion
+        /// <summary>
+        /// ToString implementation.
+        /// </summary>
+        /// <returns>A string that describes the MappedStatement</returns>
+        public override string ToString()
+        {
+            StringBuilder buffer = new StringBuilder();
+            buffer.Append("\tMappedStatement: " + this.Id);
+            buffer.Append(Environment.NewLine);
+            if (_statement.ParameterMap != null) buffer.Append(_statement.ParameterMap.Id);
 
+            return buffer.ToString();
+        }
 
-		/// <summary>
-		/// Executes the <see cref="PostBindind"/>.
-		/// </summary>
-		/// <param name="request">The current <see cref="RequestScope"/>.</param>
-		private void ExecutePostSelect(RequestScope request)
-		{
-			while (request.QueueSelect.Count>0)
-			{
-				PostBindind postSelect = request.QueueSelect.Dequeue() as PostBindind;
-
-				PostSelectStrategyFactory.Get(postSelect.Method).Execute(postSelect, request);
-			}
-		}
-	
-
-		/// <summary>
-		/// Raise an event ExecuteEventArgs
-		/// (Used when a query is executed)
-		/// </summary>
-		private void RaiseExecuteEvent()
-		{
-			ExecuteEventArgs e = new ExecuteEventArgs();
-			e.StatementName = _statement.Id;
-			if (Execute != null)
-			{
-				Execute(this, e);
-			}
-		}
-
-		/// <summary>
-		/// ToString implementation.
-		/// </summary>
-		/// <returns>A string that describes the MappedStatement</returns>
-		public override string ToString() 
-		{
-			StringBuilder buffer = new StringBuilder();
-			buffer.Append("\tMappedStatement: " + this.Id);
-			buffer.Append(Environment.NewLine);
-			if (_statement.ParameterMap != null) buffer.Append(_statement.ParameterMap.Id);
-			if (_statement.ResultMap != null) buffer.Append(_statement.ResultMap.Id);
-
-			return buffer.ToString();
-		}
-	
 
-		#endregion
+        #endregion
 
-	}
+    }
 }

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/DefaultStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/DefaultStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/DefaultStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/DefaultStrategy.cs Mon Oct 30 11:09:11 2006
@@ -50,7 +50,7 @@
 		/// <param name="target">The target.</param>
 		/// <param name="reader">The reader.</param>
 		/// <param name="keys">The keys</param>
-		public void Set(RequestScope request, ResultMap resultMap, 
+		public void Set(RequestScope request, IResultMap resultMap, 
 			ResultProperty mapping, ref object target, IDataReader reader, object keys)
 		{
 			if (mapping.TypeHandler == null || 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/IPropertyStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/IPropertyStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/IPropertyStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/IPropertyStrategy.cs Mon Oct 30 11:09:11 2006
@@ -43,7 +43,7 @@
 		/// <param name="target">The target.</param>
 		/// <param name="reader">The reader.</param>
 		/// <param name="keys">The keys</param>
-		void Set(RequestScope request, ResultMap resultMap, 
+		void Set(RequestScope request, IResultMap resultMap, 
 		         ResultProperty mapping, ref object target, 
 		         IDataReader reader, object keys);
 	}

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs Mon Oct 30 11:09:11 2006
@@ -48,14 +48,14 @@
 		/// <param name="target">The target.</param>
 		/// <param name="reader">The reader.</param>
 		/// <param name="keys">The keys</param>
-		public void Set(RequestScope request, ResultMap resultMap, 
+		public void Set(RequestScope request, IResultMap resultMap, 
 			ResultProperty mapping, ref object target, IDataReader reader, object keys)
 		{
 			// Creates object
 			object[] parameters = null;
 			bool isParameterFound = false;
 
-            ResultMap resultMapping = mapping.NestedResultMap.ResolveSubMap(reader);
+            IResultMap resultMapping = mapping.NestedResultMap.ResolveSubMap(reader);
 
             if (resultMapping.Parameters.Count > 0)
 			{

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs Mon Oct 30 11:09:11 2006
@@ -49,7 +49,7 @@
 		/// <param name="target">The target.</param>
 		/// <param name="reader">The <see cref="IDataReader"/></param>
 		/// <param name="keys">The keys</param>
-		public void Set(RequestScope request, ResultMap resultMap, 
+		public void Set(RequestScope request, IResultMap resultMap, 
 			ResultProperty mapping, ref object target, IDataReader reader, object keys)
 		{
 			// Get the select statement

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs Mon Oct 30 11:09:11 2006
@@ -53,7 +53,7 @@
         /// <param name="target">The target.</param>
         /// <param name="reader">The current <see cref="IDataReader"/></param>
         /// <param name="keys">The keys</param>
-        public void Set(RequestScope request, ResultMap resultMap,
+        public void Set(RequestScope request, IResultMap resultMap,
             ResultProperty mapping, ref object target, IDataReader reader, object keys)
         {
             // Get the select statement

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs Mon Oct 30 11:09:11 2006
@@ -51,7 +51,7 @@
 		/// <param name="target">The target.</param>
 		/// <param name="reader">The current <see cref="IDataReader"/></param>
 		/// <param name="keys">The keys</param>
-		public void Set(RequestScope request, ResultMap resultMap, 
+		public void Set(RequestScope request, IResultMap resultMap, 
 			ResultProperty mapping, ref object target, IDataReader reader, object keys)
 		{
 			// Get the select statement

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs Mon Oct 30 11:09:11 2006
@@ -52,7 +52,7 @@
 		/// <param name="target">The target.</param>
 		/// <param name="reader">The current <see cref="IDataReader"/></param>
 		/// <param name="keys">The keys</param>
-		public void Set(RequestScope request, ResultMap resultMap, 
+		public void Set(RequestScope request, IResultMap resultMap, 
 			ResultProperty mapping, ref object target, IDataReader reader, object keys)
 		{
 			// Get the select statement

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs Mon Oct 30 11:09:11 2006
@@ -97,7 +97,7 @@
 		/// <param name="target">The target.</param>
 		/// <param name="reader">The reader.</param>
 		/// <param name="selectKeys">The keys</param>
-		public void Set(RequestScope request, ResultMap resultMap, 
+		public void Set(RequestScope request, IResultMap resultMap, 
 			ResultProperty mapping, ref object target, IDataReader reader, object selectKeys)
 		{
 			string paramString = mapping.ColumnName;

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs Mon Oct 30 11:09:11 2006
@@ -26,31 +26,6 @@
 
 #region Using
 
-#region Apache Notice
-/*****************************************************************************
- * $Revision: 374175 $
- * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
- * $LastChangedBy: gbayon $
- * 
- * iBATIS.NET Data Mapper
- * Copyright (C) 2006/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;
 using System.Collections;
 using System.Data;
@@ -62,34 +37,32 @@
 using IBatisNet.DataMapper.DataExchange;
 using IBatisNet.DataMapper.Exceptions;
 using IBatisNet.DataMapper.MappedStatements.PropertyStrategy;
-using IBatisNet.DataMapper.TypeHandlers;
 
 #endregion
 
 namespace IBatisNet.DataMapper.MappedStatements
 {
     /// <summary>
-    /// Build a dynamic instance of a ResultMap
+    /// Build a dynamic instance of a <see cref="ResultPropertyCollection"/>
     /// </summary>
     public sealed class ReaderAutoMapper 
 	{
-		private ResultMap _resultMap = null;
         private static readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
+        
         /// <summary>
-        /// Initializes a new instance of the <see cref="ReaderAutoMapper"/> class.
+        /// Builds a <see cref="ResultPropertyCollection"/> for an <see cref="AutoResultMap"/>.
         /// </summary>
         /// <param name="dataExchangeFactory">The data exchange factory.</param>
         /// <param name="reader">The reader.</param>
         /// <param name="resultObject">The result object.</param>
-		public ReaderAutoMapper(DataExchangeFactory dataExchangeFactory,
+		public static ResultPropertyCollection Build(DataExchangeFactory dataExchangeFactory,
 		                        IDataReader reader,
 			                    ref object resultObject) 
 		{
         	Type targetType = resultObject.GetType();
-			_resultMap = new ResultMap(dataExchangeFactory);
-			_resultMap.DataExchange = dataExchangeFactory.GetDataExchangeForClass( targetType );
-			try 
+            ResultPropertyCollection properties = new ResultPropertyCollection();
+			
+            try 
 			{
 				// Get all PropertyInfo from the resultObject properties
 				ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(targetType);
@@ -120,7 +93,7 @@
 					if (resultObject is Hashtable) 
 					{
 						property.PropertyName = columnName;
-						_resultMap.AddResultPropery(property);
+                        properties.Add(property);
 					}
 
 					Type propertyType = null;
@@ -154,7 +127,7 @@
 						}
 
 						property.PropertyStrategy = PropertyStrategyFactory.Get(property);
-						_resultMap.AddResultPropery(property);
+                        properties.Add(property);
 					} 
 				}
 			} 
@@ -162,25 +135,9 @@
 			{
 				throw new DataMapperException("Error automapping columns. Cause: " + e.Message, e);
 			}
-		}
-
-
-        /// <summary>
-        /// AutoMap the the <see cref="IDataReader"/> to the result object.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        /// <param name="resultObject">The result object.</param>
-		public void AutoMapReader(IDataReader reader, ref object resultObject)
-		{
-			for(int index=0; index< _resultMap.Properties.Count; index++)
-
-			{
-				ResultProperty property = _resultMap.Properties[index];
-				_resultMap.SetValueOfProperty( ref resultObject, property, 
-					property.GetDataBaseValue( reader ));
-			}
+            
+            return properties;
 		}
 
 	}
-
 }

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs Mon Oct 30 11:09:11 2006
@@ -26,6 +26,7 @@
 using System.Data;
 using System.Reflection;
 using IBatisNet.Common.Logging;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
 using IBatisNet.DataMapper.Scope;
 
 namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
@@ -43,35 +44,52 @@
 		/// <param name="request">The request.</param>
 		/// <param name="reader">The reader.</param>
 		/// <param name="resultObject">The result object.</param>
-		private void AutoMapReader(RequestScope request, ref IDataReader reader,ref object resultObject) 
+        /// <returns>The AutoResultMap use to map the resultset.</returns>
+        private AutoResultMap InitializeAutoResultMap(RequestScope request, ref IDataReader reader, ref object resultObject) 
 		{
-			if (request.Statement.RemapResults)
+		    AutoResultMap resultMap  = request.CurrentResultMap as AutoResultMap;
+		    
+			if (request.Statement.AllowRemapping)
 			{
-				ReaderAutoMapper readerAutoMapper = new ReaderAutoMapper(request.DataExchangeFactory,
-					reader, 
-					ref resultObject);
-				readerAutoMapper.AutoMapReader( reader, ref resultObject );
-				_logger.Debug("The RemapResults");
+                resultMap = resultMap.Clone();
+			    
+                ResultPropertyCollection properties = ReaderAutoMapper.Build(
+                    request.DataExchangeFactory,
+                    reader,
+                    ref resultObject);
+
+                resultMap.Properties.AddRange(properties);
+
+                if (_logger.IsDebugEnabled)
+                {
+                    _logger.Debug("The Remap Result");
+                }
 			}
 			else
 			{
-				if (request.MappedStatement.ReaderAutoMapper == null)
+                if (!resultMap.IsInitalized)
 				{
-					lock (request.MappedStatement) 
+                    lock (resultMap) 
 					{
-						if (request.MappedStatement.ReaderAutoMapper == null) 
+                        if (!resultMap.IsInitalized)
 						{
-							request.MappedStatement.ReaderAutoMapper = new ReaderAutoMapper(
-								request.DataExchangeFactory,
-								reader, 
-								ref resultObject);
+                            ResultPropertyCollection properties = ReaderAutoMapper.Build(
+                               request.DataExchangeFactory,
+                               reader,
+                               ref resultObject);
+
+                            resultMap.Properties.AddRange(properties);
+                            resultMap.IsInitalized = true;
 						}
 					}
 				}
-				_logger.Debug("The AutoMapReader");
-				request.MappedStatement.ReaderAutoMapper.AutoMapReader( reader, ref resultObject );				
+                if (_logger.IsDebugEnabled)
+                {
+                    _logger.Debug("The AutoMap Reader");
+                }
 			}
-
+		    
+		    return resultMap;
 		}
 
 
@@ -90,11 +108,24 @@
 
 			if (outObject == null) 
 			{
-				outObject = request.Statement.CreateInstanceOfResultClass();
+                outObject = (request.CurrentResultMap as AutoResultMap).CreateInstanceOfResultClass();
 			}
 
-            AutoMapReader(request, ref reader, ref outObject);
+            AutoResultMap resultMap = InitializeAutoResultMap(request, ref reader, ref outObject);
 
+            // En configuration initialiser des AutoResultMap (IResultMap) avec uniquement leur class name et class et les mettres
+			// ds Statement.ResultsMap puis ds AutoMapStrategy faire comme AutoResultMap ds Java
+			// tester si la request.CurrentResultMap [AutoResultMap (IResultMap)] est initialisée 
+			// [if (allowRemapping || getResultMappings() == null) {initialize(rs);] java
+			// si ( request.Statement.AllowRemapping || (request.CurrentResultMap as AutoResultMap).IsInitalized) ....
+
+            for (int index = 0; index < resultMap.Properties.Count; index++)
+            {
+                ResultProperty property = resultMap.Properties[index];
+                resultMap.SetValueOfProperty(ref outObject, property,
+                                             property.GetDataBaseValue(reader));
+            }
+            
 			return outObject;
         }
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs Mon Oct 30 11:09:11 2006
@@ -49,11 +49,12 @@
         /// <param name="resultObject">The result object.</param>
         public object Process(RequestScope request, ref IDataReader reader, object resultObject)
         {
-			object outObject = resultObject; 
+			object outObject = resultObject;
+            AutoResultMap resultMap = request.CurrentResultMap as AutoResultMap;
 
 			if (outObject == null) 
 			{
-				outObject = request.Statement.CreateInstanceOfResultClass();
+                outObject = resultMap.CreateInstanceOfResultClass();
 			}
 
 			int count = reader.FieldCount;

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs Mon Oct 30 11:09:11 2006
@@ -49,11 +49,12 @@
         /// <param name="resultObject">The result object.</param>
         public object Process(RequestScope request, ref IDataReader reader, object resultObject)
         {
-			object outObject = resultObject; 
+			object outObject = resultObject;
+            AutoResultMap resultMap = request.CurrentResultMap as AutoResultMap;
 
 			if (outObject == null) 
 			{
-				outObject = request.Statement.CreateInstanceOfResultClass();
+                outObject = resultMap.CreateInstanceOfResultClass();
 			}
 
 			int count = reader.FieldCount;

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs Mon Oct 30 11:09:11 2006
@@ -39,7 +39,7 @@
 
         /// <summary>
         /// Processes the specified <see cref="IDataReader"/> 
-        /// when YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
+        /// when no resultClass or resultMap attribute are specified.
         /// </summary>
         /// <param name="request">The request.</param>
         /// <param name="reader">The reader.</param>