I am using the DataTable
class in C#.
I would like to know whether I should use DataTable.Select()
or DataTable.AsEnumerable().Where()
to search an element in the data table.
var filter1 = dataTable.AsEnumerable().Where(
r => r.Field<String>("OBJECT_ID").Contains(val));
var filter2 = dataTable.Select(filter expression);
LINQ is faster than SELECT for large number of rows, when rows keep increasing, you should see considerable difference. Also linq will generate less memory space compare to select(). I prefer to go with linq because the code will be more readable.
See for clear information Click Here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With