Hi all
Newbie here, but after two days of exceptions finally tracked down my own problem and thought I'd try and save anyone else from same.
Under some (and I haven't isolated them) conditions, there is a clash between System.Data.SqlTypes.SqlDateTime and System.DateTime, which appear to be (logically) the default mapping for this type.
SqlDateTime supports null, but DateTime does not. Going the other way, the default min value (zero, if you like) for DateTime isn't zero - it's midnight, 01 Jan 0001.
When you try to write this value to the SqlDateTime and into the database, somewhere, an overflow exception is thrown - the lowest value supported by SqlDateTime is midnight, 1st Jan 1753.
My fix, hopefully a correct one, is to throb a chunk of code from Type\TimeType.cs into Type\DateTimeType.cs as follows:
Line 66 of Type\DateTimeType.cs (in the public override void Set function) changes from
Code:
parm.Value = new DateTime( dateValue.Year, dateValue.Month, dateValue.Day, dateValue.Hour, dateValue.Minute, dateValue.Second );
to
Code:
if (dateValue == DateTime.MinValue)
parm.Value = DBNull.Value;
else
parm.Value = new DateTime( dateValue.Year, dateValue.Month, dateValue.Day, dateValue.Hour, dateValue.Minute, dateValue.Second );
Hopefully this is of some use, maybe even an active contributor could slide it in on the next release?
Cheers
simon.lockwood@systemic.com.au