My umbraco view has generated the following code for a macro that works fine:

@* Helper method to travers through all descendants *@
@helper Traverse(dynamic node)
{
    @* Update the level to reflect how deep you want the sitemap to go *@
    var maxLevelForSitemap = 5;

    @* Select visible children *@
    var selection = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);

    @* If any items are returned, render a list *@
    if (selection.Any())
    {
        <ul>
            @foreach (var page in selection)
            {
                <li class="level-@page.Level @(page.IsAncestorOrSelf(CurrentPage) ? "on" : null)">
                    @if (page.isNotNavigable == true)
                    {
                        <span>
                            <cite class="arrow"></cite>@page.Name
                        </span>
                    }
                    //if next line fails, add before the if below: page.HasProperty("pageRedirectTarget")
                    else if (page.HasValue("pageRedirectTarget"))
                    {
                        var redirectPage = Umbraco.Content(page.pageRedirectTarget);
                        <a href="@redirectPage.Url.Substring(0, redirectPage.Url.Length - 1)@page.pageRedirectComplement">
                            <cite class="arrow"></cite>@page.Name
                        </a>
                    }
                    else
                    {
                        <a href="@page.Url">
                            <cite class="arrow"></cite>@page.Name
                        </a>
                    }

                    @* Run the traverse helper again for any child pages *@
                    @Traverse(page)
                </li>
            }
        </ul>
    }
}

The problem happens when I added another dll (compiled in 3.5 framework) and the selection.Any() stop working, instead gives an error saying "does not contain a definition for Any()".

I know that dynamic doens't support extension methods but why does it work without me adding the reference and with it gives the error?

Can anyone help me?

thanks.

Related posts

Recent Viewed