Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whether to use select or AsEnumerable().Where() [duplicate]

Tags:

c#

linq

datatable

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);
like image 293
nbi Avatar asked Jan 03 '14 05:01

nbi


1 Answers

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

like image 161
Anto king Avatar answered Oct 20 '22 05:10

Anto king