|
From: <fab...@us...> - 2009-10-14 20:27:15
|
Revision: 4748
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4748&view=rev
Author: fabiomaulo
Date: 2009-10-14 20:27:08 +0000 (Wed, 14 Oct 2009)
Log Message:
-----------
Merge r4747 (fix NH-1973)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2009-10-14 20:25:37 UTC (rev 4747)
+++ trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2009-10-14 20:27:08 UTC (rev 4748)
@@ -19,5 +19,37 @@
{
get { return "DateTime2"; }
}
+
+ public override object Get(IDataReader rs, int index)
+ {
+ try
+ {
+ return Convert.ToDateTime(rs[index]);
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
+ }
+ }
+
+ public override void Set(IDbCommand st, object value, int index)
+ {
+ ((IDataParameter) st.Parameters[index]).Value = (DateTime) value;
+ }
+
+ public override bool IsEqual(object x, object y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
+
+ if (x == null || y == null)
+ {
+ return false;
+ }
+
+ return x.Equals(y);
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-10-14 20:25:37 UTC (rev 4747)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-10-14 20:27:08 UTC (rev 4748)
@@ -33,5 +33,14 @@
SavingAndRetrievingAction(new AllDates { Sql_datetime2 = DateTime.MaxValue },
entity => DateTimeAssert.AreEqual(entity.Sql_datetime2, DateTime.MaxValue));
}
+
+ [Test]
+ public void SaveMillisecond()
+ {
+ DateTime datetime2 = DateTime.MinValue.AddMilliseconds(123);
+
+ SavingAndRetrievingAction(new AllDates { Sql_datetime2 = datetime2 },
+ entity => Assert.That(entity.Sql_datetime2, Is.EqualTo(datetime2)));
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|