Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Frederiek Vandepitte 1 post 21 karma points
    Feb 02, 2012 @ 11:47
    Frederiek Vandepitte
    0

    Getting a System.ArgumentNullException when trying to use linq to Umb

    Hello,

    I'm trying to get info from the generated umb Data context, but whenever i use a linq expression i get a exception.

    System.ArgumentNullException: Value cannot be null.
    Parameter name: attribute
       at System.Xml.Linq.XAttribute.op_Explicit(XAttribute attribute)
       at umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml[T](XElement xml, T node)
       at umbraco.Linq.Core.Node.NodeTree`1.GetEnumerator()
       at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
       at PowerToWheels.Solex.Controls.Umbraco.usercontrols.ManageDealers.ToCsv(IEnumerable`1 dealers)

    The generated code is like this

     

    public partial class Product : DocTypeBase, IProduct
        {
            public Product()
            {
            }
            private String _LinkedAccessories;
            /// <summary>
            /// Select the accessories that can be combined with this product
            /// </summary>
            [UmbracoInfo("linkedAccessories", DisplayName = "Linked accessories", Mandatory = false)]
            [Property()]
            [System.Runtime.Serialization.DataMemberAttribute()]
            public virtual String LinkedAccessories
            {
                get
                {
                    return this._LinkedAccessories;
                }
                set
                {
                    if ((this._LinkedAccessories != value))
                    {
                        this.RaisePropertyChanging();
                        this._LinkedAccessories = value;
                        this.IsDirty = true;
                        this.RaisePropertyChanged("LinkedAccessories");
                    }
                }
            }
            private String _ColumnName;
            /// <summary>
            /// 
            /// </summary>
            [UmbracoInfo("columnName", DisplayName = "Column name", Mandatory = true)]
            [Property()]
            [System.Runtime.Serialization.DataMemberAttribute()]
            public virtual String ColumnName
            {
                get
                {
                    return this._ColumnName;
                }
                set
                {
                    if ((this._ColumnName != value))
                    {
                        this.RaisePropertyChanging();
                        this._ColumnName = value;
                        this.IsDirty = true;
                        this.RaisePropertyChanged("ColumnName");
                    }
                }
            }
            private Int32? _Image;
            /// <summary>
            /// Image shown in the main slider
            /// </summary>
            [UmbracoInfo("image", DisplayName = "Homepage Slider Image", Mandatory = false)]
            [Property()]
            [System.Runtime.Serialization.DataMemberAttribute()]
            public virtual Int32? Image
            {
                get
                {
                    return this._Image;
                }
                set
                {
                    if ((this._Image != value))
                    {
                        this.RaisePropertyChanging();
                        this._Image = value;
                        this.IsDirty = true;
                        this.RaisePropertyChanged("Image");
                    }
                }
            }
            private Int32? _OverviewImage;
            /// <summary>
            /// Image shown on the overview page
            /// </summary>
            [UmbracoInfo("overviewImage", DisplayName = "Overview image", Mandatory = false)]
            [Property()]
            [System.Runtime.Serialization.DataMemberAttribute()]
            public virtual Int32? OverviewImage
            {
                get
                {
                    return this._OverviewImage;
                }
                set
                {
                    if ((this._OverviewImage != value))
                    {
                        this.RaisePropertyChanging();
                        this._OverviewImage = value;
                        this.IsDirty = true;
                        this.RaisePropertyChanged("OverviewImage");
                    }
                }
            }
            private Int32? _ProductDetailImage;
            /// <summary>
            /// Image shown on the product detail pages
            /// </summary>
            [UmbracoInfo("productDetailImage", DisplayName = "Product detail image", Mandatory = false)]
            [Property()]
            [System.Runtime.Serialization.DataMemberAttribute()]
            public virtual Int32? ProductDetailImage
            {
                get
                {
                    return this._ProductDetailImage;
                }
                set
                {
                    if ((this._ProductDetailImage != value))
                    {
                        this.RaisePropertyChanging();
                        this._ProductDetailImage = value;
                        this.IsDirty = true;
                        this.RaisePropertyChanged("ProductDetailImage");
                    }
                }
            }
            private String _RelatedTo;
            /// <summary>
            /// 
            /// </summary>
            [UmbracoInfo("relatedTo", DisplayName = "Related to", Mandatory = false)]
            [Property()]
            [System.Runtime.Serialization.DataMemberAttribute()]
            public virtual String RelatedTo
            {
                get
                {
                    return this._RelatedTo;
                }
                set
                {
                    if ((this._RelatedTo != value))
                    {
                        this.RaisePropertyChanging();
                        this._RelatedTo = value;
                        this.IsDirty = true;
                        this.RaisePropertyChanged("RelatedTo");
                    }
                }
            }
        }
    public partial interface IProduct : IDocTypeBase
        {
            String LinkedAccessories { get; set; }
            String ColumnName { get; set; }
            Int32? Image { get; set; }
            Int32? OverviewImage { get; set; }
            Int32? ProductDetailImage { get; set; }
            String RelatedTo { get; set; }
        }

    And the only code i use is

    SolexUmbracoDataContext umbContext = new SolexUmbracoDataContext();
    StringBuilder builder = new StringBuilder();
    builder.Append(umbContext.Products.Count());
    return builder.ToString();
    

    Any1 knows why this is happening?

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies