Be careful when inserting a very precise datetime into SQL Server. (2000 or 2005, I think 2008 upped the precision on datetime.) Specifically be very careful when inserting a value of DateTime.MaxValue
If you assign MaxValue to your entity, save it, then later check for entity.Time == DateTime.MaxValue you'll probably get highly confused. This is easily solved by converting the MaxValue to the highest precision that SQL Server can handle. To do this I wrote an extension method for DateTime as follows:
Code:
public static class DateTimeExtensions
{
public static DateTime ToSQLDateTime(this DateTime dt)
{
return new DateTime(dt.Ticks - (dt.Ticks % 10000000));
}
}
Now it'll show up along with ToShortTimeString, ToLocalTime etc.
Code:
if(entity.Time == DateTime.MaxValue.ToSqlDateTime())
...