Copied to clipboard

Flag this post as spam?

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


  • greengiant83 88 posts 109 karma points
    Feb 25, 2011 @ 05:13
    greengiant83
    0

    DataProvider.Load<> returns incomplete object

    When I load an Linq to Umbraco entity via the DataProvider.Load<T>(id) method only the objects immediate properties are populated.  The childrens objects are left null so when trying to access them a NullReferenceException is thrown.

    For instance I have an AlbumList document that contains several Albums.  If I try to populate my AlbumList like this

     

    DataProvider.Load<T>(umbraco.NodeFactory.Node.getCurrentNodeId())

    Accessing the Bands object throws a nullref.  If I instead load it via a lambda like this:

    SiteDataContext.Instance.AlbumLists.Single(i => i.Id == umbraco.NodeFactory.Node.getCurrentNodeId())

    it works fine.  Is this a bug or this intended behavior? If its intended how can I get a fully populated instance using a generic type?

    I am using umbraco v 4.6.1 (Assembly version: 1.0.4029.25836)

Please Sign in or register to post replies

Write your reply to:

Draft