我有以下错误消息,我正在使用petaPOCO.我为什么会收到此错误消息以及如何收到此消息我做错了什么:
{"There is already an open DataReader associated with this Command which must be closed first."}
Run Code Online (Sandbox Code Playgroud)
This is what I have been able to copy for the exception message.
Run Code Online (Sandbox Code Playgroud)
捕获到System.InvalidOperationException消息=已经有一个与此命令关联的打开的DataReader,必须先关闭它.源= System.Data堆栈跟踪:在System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand的命令)在System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(字符串方法,SqlCommand的命令)在System.Data.SqlClient.SqlCommand.ValidateCommand(字符串System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream)中System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String方法,DbAsyncResult结果)的方法,布尔异步) ,字符串方法)在System.Data.SqlClient.SqlCommand.ExecuteScalar()在PetaPoco.Database.Insert(字符串表名,字符串primaryKeyName,布尔自动增量,对象POCO)在C:\开发\代码\ API \模型\ PetaPoco.cs :第1243行InnerException:
vin*_*w56 10
我知道这是旧的,但我想添加一些可能有助于下一个人搜索此内容的东西.如果使用Query方法,则会发生此错误.Query方法不会将所有内容加载到内存中.如果需要加载它然后关闭连接,则需要使用Fetch.
这是来自网站:
查询与提取
Database类有两种方法用于检索记录Query和Fetch.除了Fetch返回POCO的List <>之外,它们几乎完全相同,而Query使用yield return来迭代结果而不将整个集合加载到内存中.
希望这有助于其他人.
| 归档时间: |
|
| 查看次数: |
3442 次 |
| 最近记录: |