ibatis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gba...@apache.org
Subject svn commit: r381745 - /ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs
Date Tue, 28 Feb 2006 19:05:13 GMT
Author: gbayon
Date: Tue Feb 28 11:05:11 2006
New Revision: 381745

URL: http://svn.apache.org/viewcvs?rev=381745&view=rev
Log:
- Fixed IBATISNET-88

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs?rev=381745&r1=381744&r2=381745&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs Tue Feb
28 11:05:11 2006
@@ -41,6 +41,17 @@
 	internal class TimeSpanTypeHandler : 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.Value = ((TimeSpan)parameterValue).Ticks;
+        }
+
 		/// <summary>
 		/// 
 		/// </summary>
@@ -49,8 +60,16 @@
 		/// <returns></returns>
 		public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
 		{
-			//return GetValueByIndex(dataReader.GetOrdinal(columnName), dataReader);
-			return "ToDo";
+            int index = dataReader.GetOrdinal(mapping.ColumnName);
+
+            if (dataReader.IsDBNull(index) == true)
+            {
+                return System.DBNull.Value;
+            }
+            else
+            {
+                return new TimeSpan( Convert.ToInt64(dataReader.GetValue(index)) );
+            }
 		}
 
 		/// <summary>
@@ -61,10 +80,14 @@
 		/// <returns></returns>
 		public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)

 		{
-			// dépendra du dbType spécifié ds le ResultProperty (idem pour le StringTypeHandler
-			// des fois en DateTime, d'autre fois en TimeSpan
-			return "To do";
-				//dataReader.GetTimeSpan(columnIndex);
+            if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
+            {
+                return System.DBNull.Value;
+            }
+            else
+            {
+                return new TimeSpan( Convert.ToInt64(dataReader.GetValue(mapping.ColumnIndex))
);
+            }
 		}
 
 		public override object GetDataBaseValue(object outputValue, Type parameterType )



Mime
View raw message