1
的ViewComponent節我是新來查看組件,不明白爲什麼我在所有收到此錯誤。System.Threading.Tasks.Task`1 [Microsoft.AspNetCore.Html.IHtmlContent鑑於
public class Last6ClosedJobsViewComponent : ViewComponent
{
private readonly Eva804Context ctx;
public Last6ClosedJobsViewComponent(Eva804Context context)
{
ctx = context;
}
public IViewComponentResult Invoke(int id)
{
var jobs = from j in ctx.Job
.Include(j => j.Site)
.Include(j => j.WaterBody)
.Where(j => j.Site.SiteID == id && j.InvoiceDate != null)
.OrderByDescending(j => j.BookingDate)
.Take(6)
select j;
return View(jobs);
}
}
然後在默認視圖我只是想展現預訂日期的列表,在此階段:
@model IEnumerable<Eva804.Models.Job>
<h3>Recently Invoiced Jobs</h3>
<ul>
@foreach (var j in Model)
{
<li>@j.BookingDate</li>
}
</ul>
然後在網站的詳細資料,我有以下:
<div class="alert alert-success">@Component.InvokeAsync("Last6ClosedJobs",Model.SiteID)</div>
與我正在使用的示例相比,所有這些看起來都是正確的。
這是然後在視圖呈現出loverly綠色的部分,漂亮,措辭爲: System.Threading.Tasks.Task`1 [Microsoft.AspNetCore.Html.IHtmlContent]
如何找到這個錯誤?我應該在哪裏看?我的代碼有什麼不對嗎?