DataView.Rowfilter需要很多时间.

编程入门 行业动态 更新时间:2024-10-22 11:23:37
本文介绍了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需要很多时间.

本文发布于:2023-11-26 20:12:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635027.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   DataView   Rowfilter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!