运行程序时,出现以下错误: InvalidOperationException:已经存在与此命令关联的打开的DataReader,必须先关闭它。
有人可以帮助我使程序正常运行而不必对代码进行注释吗?
例如,如果我对此发表评论,
<td>
@Html.DisplayFor(modelItem => item.Cliente.Nome)
</td>
它已经可以工作了。
控制器
ViewBag.lastReservas = (from t in db.Reserva
orderby t.ID_Reserva descending
select t).Take(8);
ViewBag.lastClientes = (from t in db.Cliente
orderby t.ID_Cliente descending
select t).Take(8);
return View();
查看
<tbody>
@foreach (var item in lastReservas)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ID_Reserva)
</td>
<td>
@Html.DisplayFor(modelItem => item.Cliente.Nome)
</td>
<td>
@Html.DisplayFor(modelItem => item.DataEntrada)
</td>
<td>
@Html.DisplayFor(modelItem => item.ID_Quarto)
</td>
</tr>
}
</tbody>
<tbody>
@foreach (var item in lastClientes)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ID_Cliente)
</td>
<td>
@Html.DisplayFor(modelItem => item.Nome)
</td>
<td>
@Html.DisplayFor(modelItem => item.Morada)
</td>
<td>
@Html.DisplayFor(modelItem => item.Telemovel)
</td>
</tr>
}
</tbody>