tags:

views:

35

answers:

1

I would like to filter the rows of a DataTable and then perform a LINQ query on the resulting set of rows. The second query currently operates on a DataTable.AsEnumerable. The DataTable.Select method returns an array of DataRows. Is there anyway to perform a LINQ query on these, or convert a the array of DataRows to a DataTable, so I can chain the results of the filter into the linq query?

A: 

While you can convert the resultant array of DataRow objects to a new DataTable, your best bet is to simply perform your LINQ query against the DataRow array. For example:

var queryReturn = from r in myDataRows 
                  where (int)r["IDColumn"] == 1
                  select r;
Steve Danner