Asenumerable Select To Datatable Code Example


Example: c# datatable to linq


//You can't query against the DataTable's Rows collection, since 
//DataRowCollection doesn't implement IEnumerable<T>.
//You need to use the AsEnumerable() extension for DataTable

var results = from myRow in myDataTable.AsEnumerable()
where myRow.Field<int>("RowNo") == 1
select myRow;


//AsEnumerable() returns IEnumerable<DataRow>.
//If you need to convert IEnumerable<DataRow> to a DataTable,
//use the CopyToDataTable()

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable