Yesterday i come across NHibernate SqlDateTime overflow exception when ever i update my object. During debug i all datetime fields have there default values/entered values but when i Flush my session it throws this noughty exception :)
Data.SqlTypes.SqlTypeException with the message "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.".
after alot of findings finally i found the reason behind this. Actually I didn't map that column as a Nullable
The solution:
Make your datetime nullable either by putting ? at end of Datetime like DateTime? or Nullable<datetime>
e.g
[Property(Name = "CreatedDate", Column = "CreatedDate", NotNull = false)]//NotNull=false means null is allowed.
private DateTime? _createdDate = DateTime.Now;
I prefer using DateTime? rather then Nullable
NHibernate: SqlDateTime overflow Issue on object Update
Posted by Zafar Ullah - zafarjcp@gmail.com | 4:53 AM | Hibernate, NHibernate | 0 comments »
Subscribe to:
Post Comments (Atom)
0 comments
Post a Comment