簡體   English   中英

Umbraco剃刀宏DynamicPublishedContentList不包含以下內容的定義:

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

我的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>
    }
}

當我添加另一個dll(在3.5框架中編譯)並且selection.Any()停止工作時,就會出現問題,而是出現一條錯誤消息:“不包含Any()的定義”。

我知道動態不支持擴展方法,但是為什么在沒有添加引用的情況下它會起作用並給出錯誤?

誰能幫我?

謝謝。

並非完全是一個答案,但是對評論的時間太長了,希望對您的故障排除有所幫助。
在bin目錄中檢查以下.dll,如果您的項目不需要它們,請將其刪除。 一次刪除一個,然后在每個之后重新測試,看看是否可以固定下來。

EntityFramework.SqlServer.dll
WebGrease.dll(刪除並更新為最新)
DotNetOAuth.dll

該信息來自Umbraco論壇,尤其是下面鏈接的兩個帖子。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM