score:9

Accepted answer

i assume that datatable.select needs even more memory than enumerable.where since the latter is just a loop on the datarowcollection of the datatable whereas the old datatable.select creates new objects like select or dataexpression and it even returns new objects(datarow[]) from the query. enumerable.where just uses a predicate in a loop to determine what to return. it's also executed lazily, so you could just take, say 10 rows from the result.

var rows = dt.asenumerable()
             .where(row => row.field<int>("id") == 2)
             .take(10); // not possible with datatable.select

both are in-memory queries, so there's not a great difference.

i would chose what is more readable, powerful and maintanable and also strongly typed(field extensions): linq-to-datatable.

score:3

i suggest you to go through asp.net forum thread - datatable.select vs datatable.asenumerable().firstordefault

from: which one to use; datatable.select() or linq?

linq is generally easier to read, on my opinion, than pretty much any other form of data filtering and has the advantage over using datatable.select of being, at least partially, strongly-typed making it harder to make mistakes.

linq is faster than select for large number of rows, when rows keep increasing, you should see considerable difference.


Related Query

More Query from same tag