委托Func <list <comment>,Comment,HelperResult&gt;不带1个参数

时间:2018-01-12 14:26:56

标签: asp.net asp.net-core asp.net-core-mvc asp.net-core-2.0

错误是:

Delegate Func<List<Comment>, Comment, HelperResult> does not take 1 arguments

enter image description here

虽然我已经给出了这两个参数。我该如何修复它?

@using Jahan.Beta.Web.App.Helper
@using Jahan.Beta.Web.App.Models
@using Microsoft.AspNetCore.Mvc.Razor
@model List<Comment>

@{
Func<List<Comment>, Comment, HelperResult> ShowTree = null;
Func<List<Comment>, HelperResult> CreateTree = null;
CreateTree = (Model) => new Func<List<Comment>, HelperResult>(
@<text>@{
    List<Comment> nodesRoot = Model.Where(p => p.ParentId == null).ToList();
    <ul>
        @foreach (var comment in nodesRoot)
        {
            <li>
                <p>@comment.Description</p>

                {

                @ShowTree(Model, comment)

                }
            </li>
        }
    </ul>
}
</text>)(null);

ShowTree = (items, parentMenu) => new Func<List<Comment>, Comment, 
HelperResult>(
@<text>@{
<ul>
    @foreach (var comment in items.Where(p => p.ParentId == parentMenu.Id).ToList())
    {
        <li class="">
            <p>@comment.Description</p>
            @if (items.Children(comment).Any())
            {

                @ShowTree(items, comment)

            }
        </li>
    }
</ul>
}
</text>)(null, null);
}



<div>
   @CreateTree(Model)
</div>

0 个答案:

没有答案