There is already an open DataReader associated with this Connection which must be closed first

使用MVC4 EF Linq获取foreach列表循环的时候遇到了如下的问题:报错提示
There is already an open DataReader associated with this Connection which must be closed first

There is already an open DataReader associated with this Connection which must be closed first

解决方法如下红色所示:
@foreach (var item in Model.ToList())
{
  @Html.ActionLink(@item.user.nickname + "(微信)", "../Mess/MessInfo", new { id = item.id })
}
将Model改成Model.ToList()的就ok了

 

上一篇:如何彻底的卸载和删除Windows service


下一篇:.NetCore下ES查询驱动 PlainElastic .Net 升级官方驱动 Elasticsearch .Net