开发者

SqlDateTime overflow - Castle project ActiveRecord and SqlServer 2008

I'm using Castle project ActiveRecord and SqlServer 2008

I wanna do this :

ActiveRecordMediator<Question>.FindAll();

but i get this error :

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

I'm using datetime as type in sqlServer 2008.

I also tried with datetime2 but get the same error.

thx

Update :

Stack trace :

[SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.]
   System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value) +4838155
   System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value) +200
   System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb) +46
   System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Byte scale, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj) +4843589
   System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc) +4291
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
   NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd) +303
   NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation) +65
   NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) +1895
   NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) +307
   NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session) +1029
   NHibernate.Action.EntityUpdateAction.Execute() +740
   NHibernate.Engine.ActionQueue.Execute(IExecutable executable) +187
   NHibernate.Engine.ActionQueue.ExecuteActions(IList list) +125
   NHibernate.Engine.ActionQueue.ExecuteActions() +50
   NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) +162
   NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) +102
   NHibernate.Impl.SessionImpl.Flush() +297
   Castle.ActiveRecord.Framework.SessionFactoryHolder.ReleaseSession(ISession session) in c:\daten\dev\External\Castle\AR2.0\ActiveRecord\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:257
   Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType, Order[] orders, ICriterion[] criteria) in c:\daten\dev\External\Castle\AR2.0\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:1026
   Castle.ActiveRecord.ActiveRecordMediator.FindAll(Type targetType, Order[] orders, ICriterion[] criterias) in c:\daten\dev\External\Castle\AR2.0\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordMediator.cs:193
   Castle.ActiveRecord.ActiveRecordMediator.FindAll(Type targetType) in c:\daten\dev\External\Castle\AR2.0\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordMediator.cs:180
   Castle.ActiveRecord.ActiveRecordMediator`1.FindAll() in c:\daten\dev\External\Castle\AR2.0\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordMediator.Generic.cs:153
   StackUnderflow.Persistence.Repositories.QuestionsRepository.GetNewestQuestions(Int32 numberOfQuestions) in C:\Users\Anas\Documents\Visual Studio 2010\Projects\StackUnderflow\StackUnderflow.Persistence\Repositories\QuestionsRepository.cs:24
   StackUnderflow.Persistence.RichRepositories.RichQuestionRepository.GetNewestQuestions(Int32 numberOfQuestions) in C:\Users\Anas\Documents\Visual Studio 2010\Projects\StackUnderflow\StackUnderflow.Persistence\RichRepositories\RichQuestionRepository.cs:47
   StackUnderflow.Web.Ui.Controllers.HomeController.Index() in C:\Users\Anas\Documents\Visual Studio 2010\Projects\StackUnderflow\StackUnderflow.Web.Ui\Controllers\HomeController.cs:21
   lambda_method(ExecutionScope , ControllerBase , Object[] ) +74
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
   System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +52
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254
   System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314
   System.Web.Mvc.Controller.ExecuteCore() +105
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate&g开发者_开发技巧t;b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8682542
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


Does Question class have a DateTime type property? If it does, and it's not set to be nullable, when instantiating the class, default datetime value will be assigned, which is 01.01.01. That will cause sql exception.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜