RowFilter vs FindRows (DataView)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone tell me:
1. The real difference(s) between these 2 (apart from the obvious that
RowFilter is a Property and FindRows is a method and they return different
data type).
2. The best practice as to when one should be used in preference to the other.
I can't seem to find anywhere that shows the comparison between the 2.
Any suggestion is greatly appreciated, as always.
Calvin.
 
In my mind, I would think that rowfilter is more appropriate to use when
displaying a filtered table to a user, and findrows when you are doing
something in the background, like calculating costs for a spesific product.
 
Thanks so much for your response Paul. However, the real question still
remains: why is it more appropriate to use one than the other while both
accepts a specific criteria and return some sort of result set based on the
criteria?
 
Hi,

DataView FindRows is more appropriate to use when u want to quickly retrieve
DataRows, by finding along DataView Sort column. Coz when u Sort a DataView,
it actually creates an index along that column.

As for RowFilter, obviously it is used for filtering rows, using
easy-to-read-and-write SQL statements. But there is a cost, whenever
RowFilter or Sort is called, performance is hit, especially for a large
DataTable.

So IMHO FindRows (with Sort) is for quick retrieval of data, especially for
large data, where the DataView is initialized-once-but-used-many-times
("initialized" means RowFilter and Sort, while "used" means retrieval). While
RowFilter is for the flexibility and ease of flitering data from a developer
perspective, where DataTable is not big.

Generally I apply the initialized-once-but-used-many-times approach when
using DataView. And if necessary I can have multiple DataViews, each with
different criteria, for one DataTable.
 
Back
Top