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/11/15 21:22:01 UTC

svn commit: r475405 - in /ibatis/trunk/cs/mapper: ./ IBatisNet.Common/ IBatisNet.Common/Utilities/ IBatisNet.DataMapper.Test/Domain/ IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ IBatisNet.DataMapper.Test/bin/Debug/ IBatisNet.DataMapper/ IBatisNet.DataM...

Author: gbayon
Date: Wed Nov 15 12:22:00 2006
New Revision: 475405

URL: http://svn.apache.org/viewvc?view=rev&rev=475405
Log:
Fix for IBATISNET-104 

Added:
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/AnsiStringTypeHandler.cs   (with props)
Modified:
    ibatis/trunk/cs/mapper/IBatisNet.2003.sln
    ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.2003.sln
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.2003.sln?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.2003.sln (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.2003.sln Wed Nov 15 12:22:00 2006
@@ -38,8 +38,8 @@
 		{BBC8DA4A-EA88-41D9-8B93-929B8F3ADADE}.Debug.Build.0 = Debug|.NET
 		{BBC8DA4A-EA88-41D9-8B93-929B8F3ADADE}.Debug Test.ActiveCfg = Debug|.NET
 		{BBC8DA4A-EA88-41D9-8B93-929B8F3ADADE}.Debug Test.Build.0 = Debug|.NET
-		{BBC8DA4A-EA88-41D9-8B93-929B8F3ADADE}.Release.ActiveCfg = Debug|.NET
-		{BBC8DA4A-EA88-41D9-8B93-929B8F3ADADE}.Release.Build.0 = Debug|.NET
+		{BBC8DA4A-EA88-41D9-8B93-929B8F3ADADE}.Release.ActiveCfg = Release|.NET
+		{BBC8DA4A-EA88-41D9-8B93-929B8F3ADADE}.Release.Build.0 = Release|.NET
 		{BEFC4A45-7DF9-40E4-942C-82DC1BA5E708}.Debug.ActiveCfg = Debug|.NET
 		{BEFC4A45-7DF9-40E4-942C-82DC1BA5E708}.Debug.Build.0 = Debug|.NET
 		{BEFC4A45-7DF9-40E4-942C-82DC1BA5E708}.Debug Test.ActiveCfg = Debug|.NET

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs Wed Nov 15 12:22:00 2006
@@ -2,7 +2,7 @@
 #region Apache Notice
 /*****************************************************************************
  * $Header: $
- * $Revision: $
+ * $Revision$
  * $Date$
  * 
  * iBATIS.NET Data Mapper

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs Wed Nov 15 12:22:00 2006
@@ -76,6 +76,11 @@
             bool includeReturnValueParameter)
 		{
 #if !dotnet2
+        	// SqlCommandBuilder.DeriveParameters(<command>) does not support transactions. 
+        	// If the command is within a transaction, you will get the following error: 
+			// “SqlCommandBuilder Execute requires the command to have a transaction object 
+        	// when the connection assigned to the command is in a pending local transaction” 
+        	// even when the command object does in fact have a transaction object. 
 			using (IDbConnection connection = session.DataSource.DbProvider.CreateConnection())
 			{
 				connection.ConnectionString = session.DataSource.ConnectionString;
@@ -88,6 +93,10 @@
 				{
 #endif
 					cmd.CommandText = spName;
+
+				    // The session connection object is always created but the connection is not alwys open
+				    // so we try to open it in case.
+					session.OpenConnection();
 
 					DeriveParameters(session.DataSource.DbProvider, cmd);
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Nullable.cs Wed Nov 15 12:22:00 2006
@@ -124,12 +124,20 @@
         private Int32 _testInt32 = 0;
         private Int64 _testInt64 = 0;
         private Single _testSingle = 0;
+		private TimeSpan _testTimeSpan;
 
 		public NullableClass(int id)
 		{
 			_id = id;
 		}
 
+		public TimeSpan TestTimeSpan
+		{
+			get { return _testTimeSpan; }
+			set { _testTimeSpan = value; }
+		}
+		
+    	
         public int Id
         {
             get { return _id; }

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs Wed Nov 15 12:22:00 2006
@@ -51,6 +51,26 @@
 			Assert.IsNull(account);
 		}
 
+	    /// <summary>
+		/// Test Cache query
+		/// </summary>
+		/// <remarks>
+		/// Used trace to see that the second query don't open an new connection
+		/// </remarks>
+        [Test]
+        public void TestJIRA104()
+		{
+		    IList list = sqlMap.QueryForList("GetCachedAccountsViaResultMap", null);
+
+		    int firstId = HashCodeProvider.GetIdentityHashCode(list);
+
+		    list = sqlMap.QueryForList("GetCachedAccountsViaResultMap", null);
+
+		    int secondId = HashCodeProvider.GetIdentityHashCode(list);
+
+		    Assert.AreEqual(firstId, secondId);
+		}
+	    
 		/// <summary>
 		/// Test Cache query
 		/// </summary>
@@ -105,7 +125,7 @@
 
 			int thirdId = HashCodeProvider.GetIdentityHashCode(list);
 
-			Assert.IsTrue(firstId != thirdId);
+            Assert.AreNotEqual(firstId, thirdId);
 		}
 
 		[Test]
@@ -113,13 +133,15 @@
 		{
 			IList list = sqlMap.QueryForList("GetCachedAccountsViaResultMap", null);
 			int firstId = HashCodeProvider.GetIdentityHashCode(list);
-			list = sqlMap.QueryForList("GetCachedAccountsViaResultMap", null);
+			
+		    list = sqlMap.QueryForList("GetCachedAccountsViaResultMap", null);
 			int secondId = HashCodeProvider.GetIdentityHashCode(list);
 			Assert.AreEqual(firstId, secondId);
+		    
 			sqlMap.Update("UpdateAccountViaInlineParameters", list[0]);
 			list = sqlMap.QueryForList("GetCachedAccountsViaResultMap", null);
 			int thirdId = HashCodeProvider.GetIdentityHashCode(list);
-			Assert.IsTrue(firstId != thirdId);
+            Assert.AreNotEqual(firstId ,thirdId);
 		}
 
 		/// <summary>
@@ -148,7 +170,7 @@
 
 			int thirdId = HashCodeProvider.GetIdentityHashCode(list);
 
-			Assert.IsTrue(firstId != thirdId);
+            Assert.AreNotEqual(firstId , thirdId);
 		}
 
 		/// <summary>

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config Wed Nov 15 12:22:00 2006
@@ -31,6 +31,7 @@
   
 	<typeHandlers>
 		<typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
+    <typeHandler type="string" callback="AnsiStringTypeHandler"/>
 	</typeHandlers>
 	
   <sqlMaps>

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs Wed Nov 15 12:22:00 2006
@@ -121,6 +121,7 @@
         /// <exception cref="T:System.InvalidOperationException">The connection does not exist.-or- The connection is not open. </exception>
         int IDbCommand.ExecuteNonQuery()
         {
+            _request.Session.OpenConnection();
             return _innerDbCommand.ExecuteNonQuery();
         }
 
@@ -133,6 +134,7 @@
         /// </returns>
         IDataReader IDbCommand.ExecuteReader(CommandBehavior behavior)
         {
+            _request.Session.OpenConnection();
             return _innerDbCommand.ExecuteReader(behavior);
         }
 
@@ -144,6 +146,7 @@
         /// </returns>
         IDataReader IDbCommand.ExecuteReader()
         {
+            _request.Session.OpenConnection();
             _request.MoveNextResultMap();
             return new DataReaderDecorator(_innerDbCommand.ExecuteReader(), _request);
             
@@ -157,6 +160,7 @@
         /// </returns>
         object IDbCommand.ExecuteScalar()
         {
+            _request.Session.OpenConnection();
             return _innerDbCommand.ExecuteScalar();
         }
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Wed Nov 15 12:22:00 2006
@@ -60,6 +60,7 @@
 using IBatisNet.DataMapper.MappedStatements.ArgumentStrategy;
 using IBatisNet.DataMapper.MappedStatements.PropertyStrategy;
 using IBatisNet.DataMapper.Scope;
+using IBatisNet.DataMapper.TypeHandlers;
 
 #endregion
 
@@ -794,6 +795,9 @@
 			cacheAlias = new TypeAlias(typeof(FifoCacheController));
 			cacheAlias.Name = "FIFO";
 			_configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
+            cacheAlias = new TypeAlias(typeof(AnsiStringTypeHandler));
+            cacheAlias.Name = "AnsiStringTypeHandler";
+            _configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(cacheAlias.Name, cacheAlias);
 
 			#endregion 
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs Wed Nov 15 12:22:00 2006
@@ -225,7 +225,7 @@
 					sqlParamName = "param" + i;
 				}
 
-				IDataParameter dataParameter = _session.CreateCommand(_statement.CommandType).CreateParameter();
+                IDataParameter dataParameter = _session.CreateDataParameter();
 
 				// Manage dbType attribute if any
 				if (property.DbType != null && property.DbType.Length >0) 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj Wed Nov 15 12:22:00 2006
@@ -567,6 +567,7 @@
     <Compile Include="SqlMapSession.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="TypeHandlers\AnsiStringTypeHandler.cs" />
     <Compile Include="TypeHandlers\BaseTypeHandler.cs">
       <SubType>Code</SubType>
     </Compile>

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Wed Nov 15 12:22:00 2006
@@ -1163,6 +1163,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "TypeHandlers\AnsiStringTypeHandler.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "TypeHandlers\BaseTypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs Wed Nov 15 12:22:00 2006
@@ -148,6 +148,23 @@
 			this.OpenConnection(_dataSource.ConnectionString);
 		}
 
+        /// <summary>
+        /// Create the connection
+        /// </summary>
+        public void CreateConnection()
+        {
+            CreateConnection(_dataSource.ConnectionString);
+        }
+	    
+        /// <summary>
+        /// Create the connection
+        /// </summary>
+        public void CreateConnection(string connectionString)
+        {
+            _connection = _dataSource.DbProvider.CreateConnection();
+            _connection.ConnectionString = connectionString;
+        }
+
 		/// <summary>
 		/// Open a connection, on the specified connection string.
 		/// </summary>
@@ -156,8 +173,7 @@
 		{
 			if (_connection == null)
 			{
-				_connection =  _dataSource.DbProvider.CreateConnection();
-				_connection.ConnectionString = connectionString;
+                CreateConnection(connectionString);
 				try
 				{
 					_connection.Open();

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Wed Nov 15 12:22:00 2006
@@ -208,7 +208,6 @@
 			}
             IDalSession session = CreateSqlMapSession();
 			_sessionStore.Store(session);
-			session.OpenConnection();
 			return session;
 		}
 
@@ -222,9 +221,8 @@
 			{
 				throw new DataMapperException("SqlMap could not invoke OpenConnection(). A connection is already started. Call CloseConnection first.");
 			}
-            IDalSession session = CreateSqlMapSession();
+            IDalSession session = CreateSqlMapSession(connectionString);
 			_sessionStore.Store(session);
-			session.OpenConnection(connectionString);
 			return session;
 		}
 
@@ -278,7 +276,7 @@
 			{
 				throw new DataMapperException("SqlMap could not invoke BeginTransaction(). A Transaction is already started. Call CommitTransaction() or RollbackTransaction first.");
 			}
-            IDalSession session = CreateSqlMapSession();
+            IDalSession session = CreateSqlMapSession(connectionString);
 			_sessionStore.Store(session);
 			session.BeginTransaction( connectionString );
 			return session ;
@@ -338,7 +336,7 @@
 			{
 				throw new DataMapperException("SqlMap could not invoke BeginTransaction(). A Transaction is already started. Call CommitTransaction() or RollbackTransaction first.");
 			}
-            IDalSession session = CreateSqlMapSession();
+            IDalSession session = CreateSqlMapSession(connectionString);
 			_sessionStore.Store(session);
 			session.BeginTransaction( connectionString, isolationLevel);
 			return session;
@@ -516,7 +514,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -557,7 +554,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -604,7 +600,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -645,7 +640,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -734,7 +728,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -781,7 +774,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -825,7 +817,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -874,7 +865,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -921,7 +911,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -981,7 +970,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -1025,7 +1013,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -1069,7 +1056,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -1117,7 +1103,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -1180,7 +1165,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -1225,7 +1209,6 @@
             if (session == null)
             {
                 session = CreateSqlMapSession();
-                session.OpenConnection();
                 isSessionLocal = true;
             }
 
@@ -1273,7 +1256,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -1326,7 +1308,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -1371,7 +1352,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -1411,7 +1391,6 @@
 			if (session == null) 
 			{
                 session = CreateSqlMapSession();
-				session.OpenConnection();
 				isSessionLocal = true;
 			}
 
@@ -1642,14 +1621,32 @@
 
 		#endregion
 
-		/// <summary>
-		/// Creates a new IDalSession that will be used to query the data source.
-		/// </summary>
-		/// <returns>A new session</returns>
+
+        /// <summary>
+        /// Creates a new IDalSession that will be used to query the data source.
+        /// </summary>
+        /// <returns>A new session</returns>
         public IDalSession CreateSqlMapSession()
 		{
-			return new SqlMapSession(this);
+			SqlMapSession session = new SqlMapSession(this);
+		    session.CreateConnection();
+
+            return session;
 		}
+
+
+        /// <summary>
+        /// Creates the SQL map session.
+        /// </summary>
+        /// <param name="connectionString">The connection string.</param>
+        /// <returns>A new session</returns>
+        public IDalSession CreateSqlMapSession(string connectionString)
+        {
+            SqlMapSession session = new SqlMapSession(this);
+            session.CreateConnection(connectionString);
+
+            return session;
+        }
 
 		#endregion
 	}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/AnsiStringTypeHandler.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/AnsiStringTypeHandler.cs?view=auto&rev=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/AnsiStringTypeHandler.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/AnsiStringTypeHandler.cs Wed Nov 15 12:22:00 2006
@@ -0,0 +1,112 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 474910 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * 
+ * 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
+
+#region Using
+
+using System;
+using System.Data;
+using System.Globalization;
+
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+#endregion 
+
+namespace IBatisNet.DataMapper.TypeHandlers
+{
+    public class AnsiStringTypeHandler : BaseTypeHandler
+    {
+
+        /// <summary>
+        ///  Sets a parameter on a IDbCommand
+        /// </summary>
+        /// <param name="dataParameter">the parameter</param>
+        /// <param name="parameterValue">the parameter value</param>
+        /// <param name="dbType">the dbType of the parameter</param>
+        public override void SetParameter(IDataParameter dataParameter, object parameterValue, string dbType)
+        {
+            dataParameter.DbType = DbType.AnsiString;
+            base.SetParameter(dataParameter, parameterValue, dbType);
+        }
+        
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="mapping"></param>
+        /// <param name="dataReader"></param>
+        /// <returns></returns>
+        public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
+        {
+            int index = dataReader.GetOrdinal(mapping.ColumnName);
+
+            if (dataReader.IsDBNull(index) == true)
+            {
+                return System.DBNull.Value;
+            }
+            else
+            {
+                return dataReader.GetString(index);
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="mapping"></param>
+        /// <param name="dataReader"></param>
+        /// <returns></returns>
+        public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
+        {
+            if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
+            {
+                return System.DBNull.Value;
+            }
+            else
+            {
+                return dataReader.GetString(mapping.ColumnIndex);
+            }
+        }
+
+        public override object GetDataBaseValue(object outputValue, Type parameterType)
+        {
+            return outputValue;
+        }
+
+        public override object ValueOf(Type type, string s)
+        {
+            return s;
+        }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        public override bool IsSimpleType
+        {
+            get { return true; }
+        }
+    }
+}
+

Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/AnsiStringTypeHandler.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/AnsiStringTypeHandler.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs Wed Nov 15 12:22:00 2006
@@ -48,7 +48,7 @@
 		/// <param name="dbType">the dbType of the parameter</param>
 		public override void SetParameter(IDataParameter dataParameter, object parameterValue, string dbType)
 		{
-			dataParameter.Value =  Convert.ChangeType( parameterValue, Enum.GetUnderlyingType( parameterValue.GetType() ) );;
+			dataParameter.Value =  Convert.ChangeType( parameterValue, Enum.GetUnderlyingType( parameterValue.GetType() ) );
 		}
 
 		/// <summary>

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs?view=diff&rev=475405&r1=475404&r2=475405
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs Wed Nov 15 12:22:00 2006
@@ -61,17 +61,23 @@
 		{
 			if (parameterValue!=null)
 			{
-				ITypeHandler handler = _factory.GetTypeHandler( parameterValue.GetType(), dbType );
+			    ITypeHandler handler = _factory.GetTypeHandler( parameterValue.GetType(), dbType );
 				handler.SetParameter(dataParameter, parameterValue, dbType);
 			}
 			else
 			{
 				// When sending a null parameter value to the server,
 				// the user must specify DBNull, not null. 
-				dataParameter.Value = System.DBNull.Value;
+                dataParameter.Value = System.DBNull.Value;
 			}
 		}
 
+        /// <summary>
+        /// Gets a column value by the name
+        /// </summary>
+        /// <param name="mapping"></param>
+        /// <param name="dataReader"></param>
+        /// <returns></returns>
 		public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
 		{
 			int index = dataReader.GetOrdinal(mapping.ColumnName);
@@ -86,6 +92,12 @@
 			}		
 		}
 
+        /// <summary>
+        /// Gets a column value by the index
+        /// </summary>
+        /// <param name="mapping"></param>
+        /// <param name="dataReader"></param>
+        /// <returns></returns>
 		public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
 		{
 			if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
@@ -98,6 +110,12 @@
 			}		
 		}
 
+        /// <summary>
+        /// Converts the String to the type that this handler deals with
+        /// </summary>
+        /// <param name="type">the tyepe of the property (used only for enum conversion)</param>
+        /// <param name="s">the String value</param>
+        /// <returns>the converted value</returns>
 		public override object ValueOf(Type type, string s)
 		{
 			return s;
@@ -109,6 +127,12 @@
 		}
 
 
+        /// <summary>
+        /// Gets a value indicating whether this instance is simple type.
+        /// </summary>
+        /// <value>
+        /// 	<c>true</c> if this instance is simple type; otherwise, <c>false</c>.
+        /// </value>
 		public override bool IsSimpleType
 		{
 			get { return true; }