Copied to clipboard

Flag this post as spam?

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


  • UmbracoTests 28 posts 179 karma points
    Jun 13, 2023 @ 22:16
    UmbracoTests
    0

    nested content through code

    I am converting a v7 to v8 and in v7, it has a nested content which I have been able to recreate in v8 and it shows up in backoffice with no issues. But when I try to access it through code as follows:

    var items = Model.Value<IEnumerable<Umbraco.Core.Models.PublishedContent.IPublishedElement>>("newArticles");
    

    I am getting this error: System.NullReferenceException: Object reference not set to an instance of an object.

    Doing this:

    var hasArticles = Model.HasValue("newsArticles");
    

    hasArticles returns true

    What could be the issue?

    I see this error too:

    Object reference not set to an instance of an object.] Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory.CreateModelList(String alias) in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\PureLiveModelFactory.cs:134

Please Sign in or register to post replies

Write your reply to:

Draft