Copied to clipboard

Flag this post as spam?

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


  • Olov 27 posts 101 karma points
    Jul 02, 2010 @ 10:08
    Olov
    0

    Adding a new property to a document type breaks LINQ to Umbraco

    1. I have an existing document type and page nodes using that document type.
    2. I add a new property to the document type.
    3. I export my document types with "Export to .NET"
    4. I update the DataContext file and rebuild the project
    5. I browse in to the site and it throws an exception.

    Even if I "Republish entire site" the site is still broken, since neither the umbraco.config or the table cmsContentXml in the database and probably not the memory cache gets updated with the new property.

    I have to go in to every page that uses this document type and press save and publish.

    Is this a known issue? Are there any easy fix, maybe a package that can republish it for me?

     

  • Pauli Østerø 6 posts 28 karma points
    Jul 02, 2010 @ 19:48
    Pauli Østerø
    0

    I get the same thing as well for all properties that are not mandatory in Umbraco. Say for instance i got a DateTime field on my type, but i don't have to fill it out in Umbraco i get a conversion-error when trying to use Linq2Umbraco. If i change the type to DateTime? (nullable) i get another conversion error as well.

    There seems to be missing some kind of value-checking when populating data. Like if the field in Umbraco is empty and the field is not mandatory, well, just ignore it then... it shouldn't throw an error. The same case if the field wasn't found at all, which is the case when adding new properties after nodes are created....

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 05, 2010 @ 05:23
    Aaron Powell
    0

    Posting error messages makes it easier to try and solve the problem

  • Daniel Eriksson 1 post 21 karma points
    Jul 06, 2010 @ 11:57
    Daniel Eriksson
    0

     

    Stack Trace of error displaying if I don't save and publish every page with the changed Document type:


    [NullReferenceException: Object reference not set to an instance of an object.]
    umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml(XElement xml, T node) +2905
    umbraco.Linq.Core.Node.d__6.MoveNext() +767
    System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +147
    System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +471
    System.Linq.Enumerable.ToList(IEnumerable`1 source) +79
    Foo.Web.UserControls.MainNavigation.OnLoad(EventArgs e) in C:\projects\foo\Foo.Web\Usercontrols\MainNavigation.ascx.cs:33
    System.Web.UI.Control.LoadRecursive() +70
    System.Web.UI.Control.LoadRecursive() +189
    System.Web.UI.Control.LoadRecursive() +189
    System.Web.UI.Control.LoadRecursive() +189
    System.Web.UI.Control.LoadRecursive() +189
    System.Web.UI.Control.LoadRecursive() +189
    System.Web.UI.Control.LoadRecursive() +189
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3047

     

  • Pauli Østerø 6 posts 28 karma points
    Jul 23, 2010 @ 19:49
    Pauli Østerø
    0

    Posting answer or comment makes it easier to try and solve the problem

  • Olov 27 posts 101 karma points
    Aug 09, 2010 @ 14:37
    Olov
    0

    Pauli, the comment posted by Daniel Eriksson is the same stack trace I got when I added a new property.

  • Shannon Deminick 1526 posts 5272 karma points MVP 3x
    Aug 17, 2010 @ 05:10
    Shannon Deminick
    0

    I also get an error, but mine is different. I'm using Linq to Umbraco with my own NodeDataProvider which i pass a custom path to the XML file in. It works when there are no properties added to a doc type, but as soon as there are properties i get this exception

    [NullReferenceException: Object reference not set to an instance of an object.]
    umbraco.BusinessLogic.User.setupUser(Int32 ID) +201
    umbraco.BusinessLogic.User..ctor(Int32 ID) +238
    umbraco.UmbracoSettings.ensureSettingsDocument() +773
    umbraco.UmbracoSettings.GetKey(String Key) +61
    umbraco.UmbracoSettings.get_ForceSafeAliases() +69
    umbraco.cms.helpers.Casing.SafeAliasWithForcingCheck(String alias) +49
    umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml(XElement xml, T node) +2836
    umbraco.Linq.Core.Node.NodeTree`1.GetEnumerator() +1057
    ASP.views_site_latestmediaentries_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in d:\~FARMPROJECTS\WMA0007 - Linkin Park\branches\v1.0-MAINLINE\LinkinPark.v2\LinkinPark.Web\Views\Site\LatestMediaEntries.ascx:6
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245
    System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +84
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5273

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 17, 2010 @ 12:00
    Aaron Powell
    0

    Are you overriding NodeDataProvider or UmbracoDataProvider?

    If you're using your own custom XML document then you should override UmbracoDataProvider

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 22, 2010 @ 07:43
    Aaron Powell
    0

    I've added a change so that if the node hasn't been republished you wont have an exception thrown on new properties, they'll just be set to null, this matches what NodeFactory.Node works.

  • Olov 27 posts 101 karma points
    Aug 24, 2010 @ 11:12
    Olov
    0

    Great!

Please Sign in or register to post replies

Write your reply to:

Draft