【发布时间】:2016-10-13 17:09:54
【问题描述】:
下面的strongly typed models syntax不太明白:
@model IEnumerable<MvcMovie.Models.Movie>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Genre)
</th>
<th>
@Html.DisplayNameFor(model => model.Price)
</th>
<th>
@Html.DisplayNameFor(model => model.ReleaseDate)
</th>
<th>
@Html.DisplayNameFor(model => model.Title)
</th>
<th></th>
</tr>
</thead>
我们为什么要这样访问Genre 属性?
@Html.DisplayNameFor(model => model.Genre)
我以为这里的model指的是整个容器:
@model IEnumerable<MvcMovie.Models.Movie>
我错了吗?
【问题讨论】:
-
相信this SO post会回答你的问题。