错误是:
Delegate Func<List<Comment>, Comment, HelperResult> does not take 1 arguments
虽然我已经给出了这两个参数。我该如何修复它?
@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>