tags:

views:

91

answers:

2

hi . i have a datatable where i need to filter the record based on the condition. i know we can do it by using dataview filer condition.

is there any way we can use linq syntax filter the data table base on condition?

thank you

A: 

Sure - just use .Cast() on the table's rows and you're done:

    var qry = from row in table.Rows.Cast<DataRow>()
              where row.Field<string>("Name") == "abc"
              select row;

For a typed DataSet, I don't think even this is needed.

Note that LINQ queries the data (into a new/independent query) - it doesn't filter the existing table.

Marc Gravell
A: 

is Linq to Datasets any use?

Rob Fonseca-Ensor