Copied to clipboard

Flag this post as spam?

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


  • Thibaut Dupont 1 post 31 karma points
    1 week ago
    Thibaut Dupont
    0

    Umbraco 9 : ModelsBuilder and typed model for children elements

    Hi,

    I'm working with Umbraco 9, rc3 for a new project of mine. And I can't find a way to make ModelsBuilder works for children elements in my main page.

    I have a Blog page, where I can use the typed model thanks to the @inherits directive on top of the View.

    However, when I try to typed manually my blogPosts, I need to provide a IPublishedValueFallback and I just can't make it works somehow. I tried passing null but it fails when a property is optional.

    Here is the kind of code I would like to make it work, based on what I've been doing in Umbraco 8:

    var blogposts = blogList.Children().Select(x => new Blogpost(x));

    Thanks in advance for any help.

  • Søren Gregersen 418 posts 1720 karma points MVP 2x c-trib
    1 week ago
    Søren Gregersen
    100

    Hi,

    You could use blogList.Children().OfType<BlogPost>()

Please Sign in or register to post replies

Write your reply to:

Draft