开发者

Fluent NHibernate SqlDateTime overflow exception

开发者 https://www.devze.com 2022-12-28 14:34 出处:网络
I\'m mapping a very simple Users table, and i have a column named \'LastLoginDate\' which is defined as nullable in sql server.

I'm mapping a very simple Users table, and i have a column named 'LastLoginDate' which is defined as nullable in sql server.

My mapping looks like this :

public Users {
    Id(x => x.UserId);
    Map(x => x.UserName);
    ...
    ...
    Map(x => x.LastLoginDate).Nullable();
}

But everytime I try to save this entity programatically, i always get the SqlDateTime overflow exception. If i try to enter a manual sql statement with 'null' in this column it works.开发者_开发技巧 If i comment out just this property, it will work as well.

What can be the problem ???

Thanks in advance!


Your entity should look like this:

public class User
{
   public virtual DateTime? LastLoginDate {get;set;}
   // etc
}

Then, your map should work properly.

edit: The ? after DateTime specifies that it is Nullable, and is a short form for Nullable<DateTime>. If this isn't the cause of your error, you may want to check that Fluently.Configure specifies the correct version of SqlServer.

0

精彩评论

暂无评论...
验证码 换一张
取 消