Copied to clipboard

Flag this post as spam?

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

  • Ault Nathanielsz 71 posts 316 karma points c-trib
    Aug 17, 2019 @ 10:10
    Ault Nathanielsz

    Hi all,

    I am trying to iterate through the contents of a MNTP that is found in a different doctype to the one being modeled. My current code is:

        IPublishedContent varSettingsSite = Umbraco.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias == WtSettingsSite.ModelTypeAlias);
    IEnumerable<IPublishedContent> topnavLinks = varSettingsSite.Value("wtSettingsNavTop");
    if (topnavLinks != null)
        @foreach (var item in topnavLinks)

    Unfortunately, I am receiving the "cannot implicitly convert type object to system.collections.generic.ienumerable

    If I just make it a var, I cannot loop through it a few lines later.

    Any thoughts?

  • Shaishav Karnani from 348 posts 1627 karma points
    Aug 17, 2019 @ 14:32
    Shaishav Karnani from

    You need to use below approach to get it converted from object to IEnumerable

    var topnavLinks = varSettingsSite.Value<IEnumerable<IPublishedContent>>("wtSettingsNavTop");

    I hope that helps you.



Please Sign in or register to post replies

Write your reply to: