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
wKiom1MpUKahMBJWAANPPFMDiAs141.jpg
解決方法如下紅色所示:
@foreach (var item in Model.ToList())
{
 @Html.ActionLink(@item.user.nickname + "(微信)", "../Mess/MessInfo", new { id = item.id })
}
將Model改成Model.ToList()的就ok了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章