简体   繁体   English

Umbraco剃刀宏DynamicPublishedContentList不包含以下内容的定义:

[英]Umbraco razor macro DynamicPublishedContentList does not contain a definition for

My umbraco view has generated the following code for a macro that works fine: 我的umbraco视图为正常工作的宏生成了以下代码:

@* 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()". 当我添加另一个dll(在3.5框架中编译)并且selection.Any()停止工作时,就会出现问题,而是出现一条错误消息:“不包含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. 谢谢。

Not exactly an answer, but too long for a comment and hopefully it will help in your troubleshooting. 并非完全是一个答案,但是对评论的时间太长了,希望对您的故障排除有所帮助。
Check for the following .dlls in your bin directory and delete them if you don't need them for your project. 在bin目录中检查以下.dll,如果您的项目不需要它们,请将其删除。 Delete them one at a time and retest after each to see if you can nail it down. 一次删除一个,然后在每个之后重新测试,看看是否可以固定下来。

EntityFramework.SqlServer.dll EntityFramework.SqlServer.dll
WebGrease.dll (delete and update to latest) WebGrease.dll(删除并更新为最新)
DotNetOAuth.dll DotNetOAuth.dll

This info came from the Umbraco forums and particularly the two posts linked below. 该信息来自Umbraco论坛,尤其是下面链接的两个帖子。

https://our.umbraco.org/forum/developers/razor/45308-umbracoMacroEnginesDynamicNodeList-does-not-contain-a-definition-for-Random https://our.umbraco.org/forum/developers/razor/45308-umbracoMacroEnginesDynamicNodeList-does-not-contain-a-definition-for-Random

https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/53022-UmbracoWebModelsDynamicPublishedContentList-does-not-contain-a-definition-for-Any https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/53022-UmbracoWebModelsDynamicPublishedContentList-does-not-contain-a-definition-for-Any

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM