Try Now
More in this section

Forums / Sitefinity SDK / Edit/Create product.. Sequence contains more than one element

Edit/Create product.. Sequence contains more than one element

4 posts, 0 answered
  1. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    11 Feb 2010
    29 Apr 2011
    Link to this post
    Is this happening to anyone else?
    If I try to edit a product the products module throws an error on the following call followed by an alert in the editor that says Sequence contains more than one element. The system then sends me back to the list

            public void Copy(ProductItem source, ProductItem destination){

                this.Provider.CopyContent(source, destination);

    If I try to create a new product I get the same alert when I try to save. I've grabbed the stack trace from the wcf trace files and it appears to be taxonomy related. Is there a single point I can go to to disable the custom taxonomy for the products module?  I looked through the database and the taxonomy fields were all duplicated. After a db backup, I deleted the extras from sf_taxa and sf_meta_fields, but the error is still showing up.

    based on reflector output i think the culprit is in Telerik.Sitefinity.Taxonomies.Organizers
    private string GetTaxonomyProvider(PropertyDescriptor property)
        if (property == null)
            throw new ArgumentNullException("property");
        MetaType metaType = this.metadataManager.GetMetaType(base.DataItem.GetType());
        if (metaType == null)
            throw new InvalidOperationException("Organizers can be used only with types that are metatypes.");
        MetaField field = metaType.Fields.Where<MetaField>(delegate (MetaField f) {
            return (f.FieldName == property.Name);
        }).SingleOrDefault<MetaField>();  //<-- BOOM

    Here's the full stack trace
     <ExceptionType>System.InvalidOperationException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
                <Message>Sequence contains more than one element</Message>
                  at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
                  at Telerik.Sitefinity.Taxonomies.Organizers.DefaultOrganizer.GetTaxonomyProvider(PropertyDescriptor property)
                  at Telerik.Sitefinity.Taxonomies.Organizers.DefaultOrganizer.GetTaxonomyManager(PropertyDescriptor property)
                  at Telerik.Sitefinity.Taxonomies.Organizers.DefaultOrganizer.Clear(String propertyName)
                  at Telerik.Sitefinity.ContentLifecycleManagerExtensions.CopyDynamicFieldsRecursively(IDynamicFieldsContainer source, IDynamicFieldsContainer destination)
                  at Telerik.Sitefinity.Modules.GenericContent.ContentDataProviderBase.CopyContent(Content source, Content destination)
                  at MyNameSpace.Products.Data.ProductsManager.Copy(ProductItem source, ProductItem destination) in C:\CheckedOutRepos\MyNameSpace.svn.pond.lf\trunk\MyNameSpace.Products\Data\ProductsManager.cs:line 232
                  at Telerik.Sitefinity.Modules.GenericContent.ContentDataProviderBase.CheckOut[TContent](TContent master, Action`2 copy, IQueryable`1 itemsQuery)
                  at MyNameSpace.Products.Data.ProductsManager.CheckOut(ProductItem item) in C:\CheckedOutRepos\MyNameSpace.svn.pond.lf\trunk\MyNameSpace.Products\Data\ProductsManager.cs:line 222
                  at Telerik.Sitefinity.Modules.ContentServiceBase`5.GetContentInternal(String contentid, String providerName, String version, Boolean published, Boolean checkOut)
                  at Telerik.Sitefinity.Modules.ContentServiceBase`5.GetContent(String contentId, String providerName, String version, Boolean published, Boolean checkOut, String workflowOperation)
                  at SyncInvokeGetContent(Object , Object[] , Object[] )
                  at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)
  2. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    11 Feb 2010
    02 May 2011
    Link to this post
    So has no one else has run into this? I'm getting it when i try to use the edit/create from the backend or when I try to do create or edit with code

    here's a stack trace from the call through code

    Sequence contains more than one element

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: Sequence contains more than one element

    Source Error:


    Line 328:        public ProductItem Publish(ProductItem item)

    Line 329:        {

    Line 330:            return this.Provider.Publish(item, this.Copy, this.GetProducts());

    Line 331:        }

    Line 332:

    Source File: C:\CheckedOutRepos\MyNameSpace.svn.pond.lf\trunk\MyNameSpace.Products\Data\ProductsManager.cs    Line: 330

    Stack Trace:


    [InvalidOperationException: Sequence contains more than one element]

       DynamicModule.ns.Wrapped_OpenAccessProvider_0e6502b235d640bf88327bfc3b19ed00.ExecuteOnPublish(TContent masterItem, Action`2 copy, TContent liveItem) +281

       Telerik.Sitefinity.Modules.GenericContent.ContentDataProviderBase.Publish(TContent masterItem, Action`2 copy, IQueryable`1 itemsQuery) +757

       MyNameSpace.Products.Data.ProductsManager.Publish(ProductItem item) in C:\CheckedOutRepos\MyNameSpace.svn.pond.lf\trunk\MyNameSpace.Products\Data\ProductsManager.cs:330

       SitefinityWebApp.Models.ProductRepository.CreateProduct(ProductModel product) in C:\CheckedOutRepos\MyNameSpace.svn.pond.lf\trunk\TRH_WebProject\Models\ProductRepository.cs:62

       SitefinityWebApp.controls.ProductsUpdater.gvFCIProducts_RowCommand(Object sender, GridViewCommandEventArgs e) in C:\CheckedOutRepos\MyNameSpace.svn.pond.lf\trunk\TRH_WebProject\controls\ProductsUpdater.ascx.cs:80

       System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e) +115

       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +68

       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95

       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37

       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +121

       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37

       System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125

       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167

       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10

       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13

       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225

  3. Markus
    Markus avatar
    2763 posts
    25 Nov 2005
    05 May 2011
    Link to this post
    Dear Drew

    I get an Sequence contains more than one element simply by trying to reorder pages in the backend! This is when I use Chrome 11. When I use FF 4 - no error message but same effect - reodering does not work.

    I now this is no help to you but maybe sometimes it helps when debugin to look a bit further then what you are working on right now. It might be simply a bug somewhere else - the CMS.

  4. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    11 Feb 2010
    05 May 2011
    Link to this post
    Thanks for the reply Markus. It was definitely a problem with the custom taxonomy for me. It somehow got duplicated in the backend. 
    I put in a support ticket and it basically boiled down to running this bit of code to delete the duplicate entry from the database
    var fluent = App.WorkWith();
    var broken = fluent.DynamicData().Type(typeof(ProductItem)).Fields().Where(f => f.FieldName == "MyTaxonomyName").Get().First();
4 posts, 0 answered