DataView.Rowfilter需要很多时间. [英] DataView.Rowfilter taking much time.!!!!

查看:129
本文介绍了DataView.Rowfilter需要很多时间.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DataView.Rowfilter从表中获取特定条件的单行.
这花费了太多时间,因为我要引用一张成千上万条记录的表,大约要进行五百次...

还有其他方法可以减少相同功能的时间吗?
如果我们使用for循环是否会减少时间?

I am using DataView.Rowfilter for getting one single row from a table for particular condition.
It''s taking too much time, because I''m referring a table of thousand records around five hundred times...

Is there any other way to reduce the time for same functionality?
If we use for loop whether it will reduce the time?

推荐答案

为什么不尝试使用LINQ?

更好的是,尝试在线程池中使用多个线程.
Why don''t try you using LINQ instead?

Even better, try using multiple threads in a thread pool to do it.


是的,取消设计并重做.如果要过滤数千行,则将强制RowFilter查看这些记录中的每一个.

未对DataTable进行索引,因此无法使用RowFilter加快其速度.如果您坚持使用RowFilter,则必须在表上创建自己的索引,并根据过滤条件进行选择,然后实现一种模拟RowFilter并使用该索引来更快地找到所需行的方法.

或者,您可以跳过所有这些工作,通过让数据库为您找到一条记录,比DataView快得多,来以一种简单的方式完成操作.
Yeah, scrap your design and redo it. If you''re filtering throught thousands of rows, you''re forcing RowFilter to look at each and every one of those records.

The DataTable is not indexed, so there''s no way to speed it up using RowFilter. If you insist on using RowFilter, you''re going to have to create your own index on the table, besed on your filter criteria, then implement a method that emulates RowFilter and uses this index to find the row it needs faster.

Or, you could skip all this work and do it the easy way by having the database find that one record for you, MUCH faster than a DataView could.


这篇关于DataView.Rowfilter需要很多时间.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆