数据源的类型无效。它必须是 IListSource、IEnumerable 或 IDataSource
我正在将使用 Enterprise Library 版本 2(主要是 DAAB)的 .NET 2.0 站点升级到 .NET 版本 3.5 和 EntLib 版本 5。我已经进行了必要的更改,现在收到错误“数据源是无效类型。它必须是 IListSource、IEnumerable 或 IDataSource”。我在尝试将 DevExpress ASPxGridView 控件的数据源设置为 IDataReader 时收到此错误。
下面是我的代码。我们的应用程序广泛使用 IDataReaders...这些实例都需要修改吗?我在这里看到一篇文章说将 .ToList() 添加到数据源的末尾,但这不是 IDataReader 中的有效方法。请注意,虽然此特定文件是 C#,但我们的应用程序 99% 是用 VB.NET 编码的。
private void GetRecentAddedCasesGridData()
{
dbReader = DAL.GetRecentAddedCases(iClientKey);
if (dbReader != null)
{
GridRecentAddedCases.DataSource = dbReader;
GridRecentAddedCases.DataBind();
}
dbReader.Close();
dbReader.Dispose();
dbReader = null;
}
I'm upgrading a .NET 2.0 site that uses Enterprise Library version 2 (DAAB mainly) to .NET version 3.5 and EntLib version 5. I've made the necessary changes and now I'm getting an error "The data source is of an invalid type. It must be an IListSource, IEnumerable or IDataSource". I'm getting this error trying to set the datasource of a DevExpress ASPxGridView control to an IDataReader.
Below is my code. Our app uses IDataReaders extensively....will these instances all need to be modified? I saw one article here that said to add .ToList() to the end of the data source but that is not a valid method in the IDataReader. Please note that while this particular file is C#, 99% of our app is coded in VB.NET.
private void GetRecentAddedCasesGridData()
{
dbReader = DAL.GetRecentAddedCases(iClientKey);
if (dbReader != null)
{
GridRecentAddedCases.DataSource = dbReader;
GridRecentAddedCases.DataBind();
}
dbReader.Close();
dbReader.Dispose();
dbReader = null;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这个扩展方法
然后你可以写
GridRecentAddedCases.DataSource = dbReader.AsEnumerable()
。Try this extension method
Then you can write
GridRecentAddedCases.DataSource = dbReader.AsEnumerable()
.这是“DAAB 5 的事情”。
CodePlex 的“ctavares”表示:
“这是一个错误修复。在 Entlib 3.0 中,我们添加了对 System.TransactionScope 的支持。事实证明我们做错了,并在负载下的大型系统中导致了一些间歇性故障。以至于这个错误花费了一些大公司相当多的钱来解决这个问题,他们最终从他们的系统中完全删除了entlib,这个修复的一部分要求我们对我们拥有的数据库连接进行引用计数,这样我们就不会这样做。关闭它们,直到它们不再使用(这就是错误),因此我们需要包装数据读取器,以便我们可以正确检测读取器何时关闭并正确管理我们的连接。该错误实际上已发布在 codeplex 上。某处,但我忘记了工作项编号。”
来源:http://entlib.codeplex.com/discussions/ 211288
This is a "DAAB 5 thing".
According to "ctavares" at CodePlex:
"This was a bug fix. In Entlib 3.0, we added support for System.TransactionScope. It turns out we did it wrong, and caused some intermittent failures in large systems under load. To the point that the bug cost some large companies quite a bit of money in figuring out the problem, and they ended up removing entlib from their system completely. Part of this fix required that we do reference counting on database connections that we own so that we don't close them down until they're no longer used (which was the bug). As such, we needed to wrap data readers so we could properly detect when a reader was closed and manage our connections correctly. The bug was actually posted here on codeplex somewhere, but I forget the work item number. "
Source: http://entlib.codeplex.com/discussions/211288