Modelsbuilder: still possible to get IPublishedContent somehow?
hello - the Modelsbuilder docs say:
In other words, when using the Models Builder, the content cache does
not return IPublishedContent objects anymore, but strongly typed
models.
that's great for views and all, but is there still a way to get the original IPC and not a strongly typed model? "Umbraco.Content(id)" doesn't seem to have an overload, is there another way?
I am introducing/converting my project to Modelsbuilders but i have some existing controller code that would be easier to leave as-is dealing in IPCs.
If you have the strongly typed model, you can convert it to IPublishedContent explicitly with a cast, however if your model is, for example, a nested content object, then it's not an IPublishedContent, but instead an IPublishedElement. The Models Builder models implement either of these classes (I don't think they implement both).
Also, Umbraco.Content returns IPublishedContent I believe, but if you look at it in the Visual Studio Watch Window, you will also see that it is the strongly typed model.
Modelsbuilder: still possible to get IPublishedContent somehow?
hello - the Modelsbuilder docs say:
that's great for views and all, but is there still a way to get the original IPC and not a strongly typed model? "Umbraco.Content(id)" doesn't seem to have an overload, is there another way?
I am introducing/converting my project to Modelsbuilders but i have some existing controller code that would be easier to leave as-is dealing in IPCs.
thanks
Hi Andrew,
If you have the strongly typed model, you can convert it to
IPublishedContent
explicitly with a cast, however if your model is, for example, a nested content object, then it's not an IPublishedContent, but instead an IPublishedElement. The Models Builder models implement either of these classes (I don't think they implement both).Also,
Umbraco.Content
returns IPublishedContent I believe, but if you look at it in the Visual Studio Watch Window, you will also see that it is the strongly typed model.Cheers,
Nik
thanks for the info Nik :)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.