无法将Lambda表达式转换为类型“ CancellationToken”,因为它不是委托类型

时间:2019-12-14 20:21:12

标签: asynchronous model-view-controller parameters

我是MVC的新手,不确定如何解决此错误。我需要根据通过参数传递的ID列出项目详细信息。有没有其他写方法,可以使我看不到标题中的错误?

.ToListAsync(d => d.ItemDetailId == id)

控制器

public async Task<IActionResult> Details(int? id)
        {
            if (id == null)
            {
                return NotFound();            }


            var itemDetail = await _context.ItemDetail
                .Include(i => i.MenuItem)
                .ToListAsync(d => d.ItemDetailId == id);
            if (itemDetail == null)
            {
                return NotFound();
            }

            return View(itemDetail);
        }

接收详细信息操作视图

@model Farbucks.Models.ItemDetail

@{
    ViewData["Title"] = "Details";
}

<h2>Details</h2>

<div>
    <h4>ItemDetail</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt>
            @Html.DisplayNameFor(model => model.Size)
        </dt>
        <dd>
            @Html.DisplayFor(model => model.Size)
        </dd>
        <dt>
            @Html.DisplayNameFor(model => model.Price)
        </dt>
        <dd>
            @Html.DisplayFor(model => model.Price)
        </dd>
        <dt>
            @Html.DisplayNameFor(model => model.MenuItem)
        </dt>
        <dd>
            @Html.DisplayFor(model => model.MenuItem.Name)
        </dd>
    </dl>
</div>


<div>
    <a asp-controller="MenuItems" asp-action="Index">Back to List</a>
</div>

0 个答案:

没有答案