Orchard CMS 重复内容错误
Orchard CMS Duplicate Content Error
我们有一个使用 Orchard CMS v1.8 构建的网站。我们遇到过几个管理内容的人无法将更改保存到页面的实例。他们收到以下错误。
An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back
Sequence contains more than one matching element
System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func
2 predicate) at Orchard.ContentManagement.DefaultContentManager.BuildNewVersion(ContentItem existingContentItem) in c:\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 450 at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in c:\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 234 at Orchard.Core.Contents.Controllers.AdminController.EditPOST(Int32 id, String returnUrl, Action1 conditionallyPublish) in c:\Orchard\src\Orchard.Web\Core\Contents\Controllers\AdminController.cs:line 308 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.b__41()
如何消除 SingleOrDefault() 调用中返回的额外记录?我对 Orchard 背后的数据库结构的了解不足以找到 "content records",但如果我能够找到它们,我可以删除额外的记录。
谢谢!
此错误的原因是您有多个具有值 Latest = 1
的相同内容项的版本(果园使用此值来确定内容项的最新版本),要解决它,您可以 运行 以下查询查找重复版本:
SELECT *
FROM Orchard_Framework_ContentItemVersionRecord
WHERE ContentItemRecord_id = @Id
然后确保只有一条记录值为Latest = 1
,published = 1
,并且Number
是有序的,没有重复。
仅供参考,在查询中对有错误的内容项使用值 Id
。
我们有一个使用 Orchard CMS v1.8 构建的网站。我们遇到过几个管理内容的人无法将更改保存到页面的实例。他们收到以下错误。
An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back Sequence contains more than one matching element System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable
1 source, Func
2 predicate) at Orchard.ContentManagement.DefaultContentManager.BuildNewVersion(ContentItem existingContentItem) in c:\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 450 at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in c:\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 234 at Orchard.Core.Contents.Controllers.AdminController.EditPOST(Int32 id, String returnUrl, Action1 conditionallyPublish) in c:\Orchard\src\Orchard.Web\Core\Contents\Controllers\AdminController.cs:line 308 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.b__41()
如何消除 SingleOrDefault() 调用中返回的额外记录?我对 Orchard 背后的数据库结构的了解不足以找到 "content records",但如果我能够找到它们,我可以删除额外的记录。
谢谢!
此错误的原因是您有多个具有值 Latest = 1
的相同内容项的版本(果园使用此值来确定内容项的最新版本),要解决它,您可以 运行 以下查询查找重复版本:
SELECT *
FROM Orchard_Framework_ContentItemVersionRecord
WHERE ContentItemRecord_id = @Id
然后确保只有一条记录值为Latest = 1
,published = 1
,并且Number
是有序的,没有重复。
仅供参考,在查询中对有错误的内容项使用值 Id
。