Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi there
When I am using a partial view:
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var selection = Model.Content.Site().Children.Where("umbracoFooterNav"); }
Umbraco returns in Visual Studio
This method uses dynamics which will be removed in future versions, use strongly typed syntax instead''
But I was under the impression that Model.Content was the strongly typed. What is wrong with my partial view?
Hi Elitenet,
I'm not sure, but I think it is your use of Children and you use of Where that is resulting in the dynamic result.
Model.content.Site(), is as far as I know returning an strongly typed implementation.
Try changing Children to Children() and Where to a full LINQ expression.
Thanks,
Nik
Hi,
I can see that Nik was faster than me, but here goes anyways:
Your view itself is actually fine. It is the Where method and the way that you use it that gives a warning, as it uses dynamics internally. Your code could be changed to:
Where
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var selection = Model.Content.Site().Children.Where(x => x.DocumentTypeAlias == "umbracoFooterNav"); }
Then you'll keep using the strongly typed models, and the warning is gone ;)
Okay thanks.
I think I have mixed it up during an recode from @Currentpage to @Model. Makes sense that it originally was CurrentPage.
Funny that the warning wasnt there originally. I think the warning came when I later upgraded whole umbraco code to 7.7.9.
Well that's something to look out for when projects are going to be recoded to Strongly Types.
thanks again :-)
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.
Continue discussion
Partial View and Strongly Typed
Hi there
When I am using a partial view:
Umbraco returns in Visual Studio
This method uses dynamics which will be removed in future versions, use strongly typed syntax instead''
But I was under the impression that Model.Content was the strongly typed. What is wrong with my partial view?
Hi Elitenet,
I'm not sure, but I think it is your use of Children and you use of Where that is resulting in the dynamic result.
Model.content.Site(), is as far as I know returning an strongly typed implementation.
Try changing Children to Children() and Where to a full LINQ expression.
Thanks,
Nik
Hi,
I can see that Nik was faster than me, but here goes anyways:
Your view itself is actually fine. It is the
Where
method and the way that you use it that gives a warning, as it uses dynamics internally. Your code could be changed to:Then you'll keep using the strongly typed models, and the warning is gone ;)
Okay thanks.
I think I have mixed it up during an recode from @Currentpage to @Model. Makes sense that it originally was CurrentPage.
Funny that the warning wasnt there originally. I think the warning came when I later upgraded whole umbraco code to 7.7.9.
Well that's something to look out for when projects are going to be recoded to Strongly Types.
thanks again :-)
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.