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

 

There is already an open DataReader associated with this Connection which must be closed first的更多相关文章

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

    废话不多说,直接 上图,及解决办法.不过问题还不是太清楚到底为什么会出现这个情况..........  

  2. There is already an open DataReader associated with this Command which must be closed first." exception in Entity Framework

    Fixing the "There is already an open DataReader associated with this Command which must be clos ...

  3. 在实体对象中访问导航属性里的属性值出现异常“There is already an open DataReader associated with this Command which must be closed first”

    在实体对象中访问导航属性里的属性值出现异常“There is already an open DataReader associated with this Command which must be ...

  4. 关于MultipleActiveResultSets属性导致的There is already an open DataReader associated with this Command which must be closed first的解决方法

    执行SqlDataReader.Read之后,如果还想用另一个SqlCommand执行Insert或者Update操作的话,会得到一个错误提示:There is already an open Dat ...

  5. 多线程下,多次操作数据库报错,There is already an open DataReader associated with this Command which must be closed first.

    原文:https://www.cnblogs.com/sdusrz/p/4433108.html 执行SqlDataReader.Read之后,如果还想用另一个SqlCommand执行Insert或者 ...

  6. error 'there is already an open datareader associated with this command which must be closed first'

    This can be easily solved by allowing MARS in your connection string. Add MultipleActiveResultSets=t ...

  7. There is already an open DataReader associated with this Command which must be closed first

    通常出现在嵌套查询数据库(比如在一个qry的遍历时,又进行了数据库查询) 通过在连接字符串中允许MARS可以轻松解决这个问题. 将MultipleActiveResultSets = true添加到连 ...

  8. static,你还敢用吗?(二)

    为了压系统,昨天小组在测试环境模拟了一大批订单数据.今天上午查看记录的账单计息日志,发现了一大堆的MySqlException MySql.Data.MySqlClient.MySqlExceptio ...

  9. 使用OData技术遇到的问题及解决办法

    “System.NotSupportedException”类型的未经处理的异常在 Microsoft.Data.Services.Client.dll 中发生 其他信息: 对此 POST 请求的响应 ...

随机推荐

  1. .NET垃圾回收与内存泄漏

    相信大家一定听过,看过甚至遇到过内存泄漏.在 .NET 平台也一定知道有垃圾回收器,它可以让开发人员不必担心内存的释放问题,因为它会自定管理内存.但是在 .NET 平台下进行编程,绝对不会发生内存泄漏 ...

  2. Build Android-x86 ICS 4 Virtualbox from Google Virtualbox Target and Intel Kernel 编译体验

    最近一直在研究android源码的编译,应该说研究的很辛苦,最难的是下源码,总是不停的断掉,最后感谢公司的高网速,找到方法后12G的源码只花了1个小时就下完了. 参考以下网址:http://softw ...

  3. Cloudera Manager(CentOS)安装介绍

    相信通过这篇文章大家都对Cloudera Manager及CDH安装有一个整体的认识 目 录 1           准备工 作.................................... ...

  4. js中的 window.location、document.location、document.URL 对像的区别(转载)

    原文:http://www.cr173.com/html/18417_1.html 当我们需要对html网页进行转向的时候或是读取当前网页的时候可以用到下面三个对像: window.location. ...

  5. gchart 插件API

    data: 一个二维数组,参数类型如下:[[, , ], [, , ], [, , ]] size: 图片显示的大小 ( width x height ) 300x200 type: 前面已经说过了 ...

  6. shell脚本中的括号和实例

    1.单圆括号和双圆括号 “双圆括号”命令允许将高级的数学表达式放入比较中.格式如下: (( expression )) 除了 test命令(if-then [])使用的标准数学运算符外, 双圆括号还支 ...

  7. Mac系统下安装PIL

    安装PIL依赖JPEG.Freetype.LittleCMS, 首先安装这三个环境(第一至三步): 第一步:安装JPEG http://www.ijg.org/files/jpegsrc.v8c.ta ...

  8. python对比两个文件问题

    写一个比较两个文本文件的程序. 如果不同, 给出第一个不同处的行号和 列号. 比较的时候可以使用zip()函数 a=open('test.txt','r') b=open('test2.txt','r ...

  9. 未能写入输出文件 c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary

    ERROR: 未能写入输出文件“c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/.... 一般遇到 ...

  10. html5 本地存储

    < ![CDATA[ 1. html本地存储操作 首先引用 <script src="Scripts/jquery-2.0.0.js"></script&g ...