public class aaa
{
public List<emp> emps { set; get; }
public List<dept> depts { set; get; }
}
public ActionResult detail()
{
aaa a = new aaa();
a.emps = (from p in db.emps select p).ToList();
a.depts = (from p in db.depts select p).ToList();
return View(a);
}
答案 0 :(得分:1)
查看 中的模型应为@model data.Models.aaa
。
@model data.Models.aaa
<table>
@foreach (var emp in Model.emps)
{
<tr>
<td>@emp.FirstName</td>
</tr>
}
</table>
<table>
@foreach (var dept in Model.depts)
{
<tr>
<td>@dept.Title</td>
</tr>
}
</table>