Author: gbayon
Date: Fri May 19 10:56:31 2006
New Revision: 407864

URL: http://svn.apache.org/viewvc?rev=407864&view=rev
Log:
- Fix for DbHelperParameterCache

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs

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?rev=407864&r1=407863&r2=407864&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs 
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs 
Fri May 19 10:56:31 2006
@@ -2,7 +2,7 @@
 #region Apache Notice
 /*****************************************************************************
  * $Header: $
- * $Revision: $
+ * $Revision$
  * $Date$
  * 
  * iBATIS.NET Data Mapper
@@ -58,22 +58,34 @@
                /// <returns></returns>
                private static IDataParameter[] 
DiscoverSpParameterSet(IDalSession session, string spName, bool 
includeReturnValueParameter)
                {
-                       return 
InternalDiscoverSpParameterSet(session.DataSource.DbProvider, 
session.Connection, spName, includeReturnValueParameter);  
+                       return InternalDiscoverSpParameterSet(
+                session.DataSource.DbProvider, 
+                session.Connection, 
+                session.Transaction,
+                spName, 
+                includeReturnValueParameter);  
                }
 
-               /// <summary>
-               /// resolve at run time the appropriate set of Parameters for a 
stored procedure
-               /// </summary>
-               /// <param name="provider"></param>
-               /// <param name="connection">a valid open IDbConnection</param>
-               /// <param name="spName">the name of the stored 
procedure</param>
-               /// <param name="includeReturnValueParameter">whether or not to 
include their return value parameter</param>
-               /// <returns></returns>
+
+        /// <summary>
+        /// Discover at run time the appropriate set of Parameters for a 
stored procedure
+        /// </summary>
+        /// <param name="provider">The provider.</param>
+        /// <param name="connection">A valid open <see 
cref="IDbConnection"/>.</param>
+        /// <param name="transaction">A <see cref="IDbTransaction"/>.</param>
+        /// <param name="spName">Name of the stored procedure.</param>
+        /// <param name="includeReturnValueParameter">if set to <c>true</c> 
[include return value parameter].</param>
+        /// <returns>The stored procedure parameters.</returns>
                private static IDataParameter[] 
InternalDiscoverSpParameterSet(IDbProvider provider,
-                       IDbConnection connection, string spName, bool 
includeReturnValueParameter)
+                       IDbConnection connection, IDbTransaction transaction, 
string spName, 
+            bool includeReturnValueParameter)
                {
                        using (IDbCommand cmd = connection.CreateCommand())
                        {
+                if (transaction != null)
+                {
+                    cmd.Transaction = transaction;
+                }
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.CommandText = spName;
 

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs?rev=407864&r1=407863&r2=407864&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
 Fri May 19 10:56:31 2006
@@ -116,6 +116,29 @@
                        Assert.IsNotNull(testAccount);
                        Assert.AreEqual(99, testAccount.Id);
                }
+
+        /// <summary>
+        /// Test DBHelperParameterCache in transaction
+        /// </summary>
+        [Test]
+        public void TestDBHelperParameterCache()
+        {
+            Account account = new Account();
+
+            account.Id = 99;
+            account.FirstName = "Achille";
+            account.LastName = "Talon";
+            account.EmailAddress = "[EMAIL PROTECTED]";
+
+            sqlMap.BeginTransaction();
+            sqlMap.Insert("InsertAccountViaStoreProcedure", account);
+
+            Account testAccount = 
sqlMap.QueryForObject("GetAccountViaColumnName", 99) as Account;
+            sqlMap.CommitTransaction();
+
+            Assert.IsNotNull(testAccount);
+            Assert.AreEqual(99, testAccount.Id);
+        }
                #endregion
        }
 }

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs?rev=407864&r1=407863&r2=407864&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs
 Fri May 19 10:56:31 2006
@@ -78,7 +78,8 @@
                /// <param name="dataBaseValue"></param>
                public override void SetData(ref object target, ResultProperty 
mapping, object dataBaseValue)
                {
-            if (target.GetType() != _parameterClass)
+            if ( (target.GetType() != _parameterClass)
+                && !_parameterClass.IsSubclassOf(target.GetType())) 
                        {
                 throw new ArgumentException("Could not set value of type '" + 
target.GetType() + "' in property '" + mapping.PropertyName + "' of type '" + 
_parameterClass + "'");
                        }


Reply via email to