C# datetime Exception on insert query using Nhibernate and MS sql server
Getting exception while saving
Entity -
public class AuditCaseAccess : BaseClass
{
public virtual int UserID { get; set; }
public virtual int CaseID { get; set; }
public virtual DateTime CaseAccessTime { get; set; }
}
Mapper -
class AuditCaseAccessMap : ClassMap<AuditCaseAccess>
{
public AuditCaseAccessMap()
{
Id(x => x.ID);
Map(x=>x.UserID);
Map(x=>x.CaseID);
Map(x=>x.CaseAccessTime);
Table("tbl_AuditCaseAccess");
}
}
Save Method -
public bool Save(T persistableEntity)
{
if (persistableEntity != null)
{
session.BeginTransaction();
session.Save(persistableEntity);
session.Transaction.Commit();
return true;
}
return false;
}
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
But on Sql profiler insert query seems to be right -
exec sp_executesql N'INSERT INTO dbo.tbl_AuditCaseAccess (UserID, CaseID, CaseAccessTime) VALUES (@p0, @p1, @p2); select SCOPE_IDENTITY()',N'@p0 int,@p1 int,@p2 datetime',@p0=1060,@p1=16205,@p2='2016-03-29 17:30:58'
链接地址: http://www.djcxy.com/p/26976.html
上一篇: 如何让Android服务与活动进行通信