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));
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 passingnull
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.
Hi,
You could use
blogList.Children().OfType<BlogPost>()
Hi
I have something like this,
But that don't work..
Is there a better why to do it ?
is working on a reply...