使用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了