.net - Why does DataTable.Rows not have a .Where() method? -


i syntax offered .where() method available many collections. however, i've noticed conspicuously absent collections.

i'm sure has interface being implemented or not implemented, beyond that, know why don't have .where() method on datatable.rows

datarowcollection implements ienumerable, not ienumerable<datarow>.

an extension method exists - datatableextensions.asenumerable - "fix" this. call table.cast<datarow>() enumerablerowcollection returned asenumerable has bit more functionality on it.

so can write:

var query = row in table.asenumerable()             ...             select ...; 

there other useful extension methods in datarowextensions, notably field, can write:

var query = row in table.asenumerable()             row.field<int>("age") > 18             select row.field<string>("name"); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -