开发者

Unable to use Orchard ContentPart with ntext column

I have a table created in the sql ce database for my content part "CourseDescription". The "Sy开发者_JAVA技巧llabus" column uses ntext as it's type. However, when I try to create a CourseDescription I get the following exception:

[InvalidOperationException: @p1 : String truncation: max=4000, len=11501, value='<p>
<strong>About this Course</strong><br /> ...


  System.Data.SqlServerCe.SqlCeCommand.FillParameterDataBindings(Boolean verifyValue) +914
   System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options) +614
   System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() +21
   NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd) +297
   NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation) +16
   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) +968
   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) +195
   NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session) +354
   NHibernate.Action.EntityUpdateAction.Execute() +399
   NHibernate.Engine.ActionQueue.Execute(IExecutable executable) +117
   NHibernate.Engine.ActionQueue.ExecuteActions(IList list) +92
   NHibernate.Engine.ActionQueue.ExecuteActions() +27
   NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) +121
   NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) +56
   NHibernate.Impl.SessionImpl.Flush() +292
   NHibernate.Transaction.DistributedTransactionContext.System.Transactions.IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment) +395

[TransactionAbortedException: The transaction has aborted.]
   System.Transactions.TransactionStateAborted.EndCommit(InternalTransaction tx) +11
   System.Transactions.CommittableTransaction.Commit() +239
   System.Transactions.TransactionScope.InternalDispose() +402
   System.Transactions.TransactionScope.Dispose() +1450
   Orchard.Data.TransactionManager.System.IDisposable.Dispose() in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Data\TransactionManager.cs:43
   Autofac.Core.Disposer.Dispose(Boolean disposing) +79
   Autofac.Util.Disposable.Dispose() +46
   Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) +21
   Autofac.Util.Disposable.Dispose() +46
   Orchard.Environment.<>c__DisplayClass2.<.ctor>b__0() in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Environment\WorkContextAccessor.cs:75
   Orchard.Environment.HttpContextScopeImplementation.System.IDisposable.Dispose() in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Environment\WorkContextAccessor.cs:80
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Mvc\Routes\ShellRoute.cs:158
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8862381
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

How can I get around this?


Try to use the StringLengthMax attribute on your Syllabus property inside record class, like:

[StringLengthMax]
public virtual string Syllabus { get; set; }

This will make NHibernate aware of the unlimited length.

HTH

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜