model_12 つのモデルとmodel_2(one model_1, many )を使用したいのですmodel_2が、1 つのビューでは 1 つしか使用できません。
これは私の見解です:
@model IEnumerable<ProjectFashion.Models.model_1>
@model IEnumerable<ProjectFashion.Models.model_2>
@{
ViewBag.Title = "VMenu";
}
<ul>
@foreach(var n in Model) {
<li class="dir">
<h6>@n.name</h6>
<ul>
@*I WANT TO GET model_2 which belongs to model_1*@
</ul>
</li>
}
</ul>
と私の _Layout.cshtml:
<!--vmenu-->
@Html.Action("VMenu", "Layout")
<!--vmenu-->
と私の LayoutController.cs:
ShopContent db = new ShopContent();
public ActionResult VMenu() {
return PartialView("_VMenu", db.model_1s);
}
私もandmodel_3を含めて使っていますが、 ではいくつかの問題が発生します。(私の不完全な英語で申し訳ありません...)model_1model_2@Html.Action("VMenu", "Layout")