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

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

 

posted @ 2014-03-19 15:46  坚持の承诺  阅读(1165)  评论(0编辑  收藏  举报