Scaffolding Option を使用してSubscriptionController
.
以下にいくつかのコード スニペットを示します。
In Controller:
public ActionResult Index()
{
var subscriptions = db.Subscriptions;
return View(subscriptions.ToList());
}
In View:
@model IEnumerable<Liquidity.Domain.Entity.Subscription>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Amount)
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Amount)
</td>
</td>
</tr>
}
</table>
For my subscription model, I have:
public decimal Amount { get; set; }
ここに私の質問があります:
これは次のように、1 つのIDではなく LISTに
Model
バインドされていると思いました。Subscription
Subscription
@foreach (モデル内の変数項目)
これは正しいです?
1 が正しい場合、この行の理由:
@Html.DisplayNameFor(model => model.Amount)
モデルは
Amount
?これは、モデルが単一の「サブスクリプション」にバインドされていることを示唆しています。この行の場合:
@Html.DisplayFor(modelItem => item.Amount)
modelItem と item は何にバインドされていますか? ラムダがmodelItemを受け入れるのに使用しないのはなぜですか?
Model、model、および modelitem がバインドされているものを正確に説明してください。
ありがとう。