评估 LINQ 查询时确定进度
我的 C# 程序长期执行针对 MS SQL Server 数据库运行的 LINQ 查询。我想在执行查询时向用户显示进度。有没有办法了解LINQ执行进度?当然,我可以显示不确定的进度,但如果可能的话,我更喜欢确定的。
My C# program has long executed LINQ query running against MS SQL Server database. I'd like to show user a progress while executing the query. Is there any way to understand LINQ execution progress? Of course I can show undeterminate progress, but if possible, I'd prefer determinate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它实际上与 LINQ 查询无关,而是与底层提供程序有关。由于 SQL Server 对于任何给定的查询没有任何进度概念,因此 LINQ 也没有。无论如何,即使底层数据源有一些进度概念,LINQ 框架也没有挂钩将其转发给调用者。所以,不幸的是,答案是否定的。
It's not really about the LINQ query, but rather that of the underlying provider. As SQL Server doesn't have any notion of progress for any given query, LINQ cannot either. Regardless, even if the underlying datasource had some notion of progress, the LINQ framework does not have hooks to relay this to the caller. So, the answer is no, unfortunately.
使用 LINQtoSQL 无法做到这一点。 LINQtoSQL 只是将 LINQ 查询转换为 SQL 查询并将其发送到数据库。然后您只需等待数据库返回结果即可。没有办法为此取得任何进展。
There is no way to do that using LINQtoSQL. LINQtoSQL simply translates your LINQ query to a SQL query and sends it to the database. Then you simply wait until the database returns with results. There is no way to get any progress for that.