Fluent NHibernate CheckProperty and Dates
- by Chris C
I setup a NUnit test as such:
new PersistenceSpecification<MyTable>(_session)
.CheckProperty(c => c.ActionDate, DateTime.Now);
When I run the test via NUnit I get the following error:
SomeNamespace.MapTest:
System.ApplicationException : Expected '2/23/2010 11:08:38 AM' but got
'2/23/2010 11:08:38 AM' for Property 'ActionDate'
The ActionDate field is a datetime field in a SQL 2008 database. I use Auto Mapping and declare the ActionDate as a DateTime property in C#.
If I change the test to use DateTime.Today the tests pass.
My question is why is the test failing with DateTime.Now? Is NHibernate losing some precision when saving the date to the database and if so how do prevent the lose? Thank you.