.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

c# - Getting "Internal .Net Framework Data Provider error 30" error when column has NULL value -

SAP Web Service from .NET via WCF -

c++ - How to modify context menu of internet explorer using IDocHostUIHandler::ShowContextMenu? -