DataView.RowFilter Vs DataTable.Select() vs DataTable.Rows.Find()
Posted
by Aseem Gautam
on Stack Overflow
See other posts from Stack Overflow
or by Aseem Gautam
Published on 2010-05-14T06:43:46Z
Indexed on
2010/05/17
5:50 UTC
Read the original article
Hit count: 1244
Considering the code below:
Dataview someView = new DataView(sometable)
someView.RowFilter = someFilter;
if(someView.count > 0) { …. }
Quite a number of articles which say Datatable.Select() is better than using DataViews, but these are prior to VS2008.
Solved: The Mystery of DataView's Poor Performance with Large Recordsets
Array of DataRecord vs. DataView: A Dramatic Difference in Performance
Googling on this topic I found some articles/forum topics which mention Datatable.Select() itself is quite buggy(not sure on this) and underperforms in various scenarios.
On this(Best Practices ADO.NET) topic on msdn it is suggested that if there is primary key defined on a datatable the findrows() or find() methods should be used insted of Datatable.Select().
This article here (.NET 1.1) benchmarks all the three approaches plus a couple more. But this is for version 1.1 so not sure if these are valid still now. Accroding to this DataRowCollection.Find() outperforms all approaches and Datatable.Select() outperforms DataView.RowFilter.
So I am quite confused on what might be the best approach on finding rows in a datatable. Or there is no single good way to do this, multiple solutions exist depending upon the scenario?
© Stack Overflow or respective owner