I have a DataTable. I would like to filter DataRows where City = "Hongkong".
How to apply LINQ against DataRow?
var result = dr.Where(r => r.Field<string>("City") == "Hongkong");
您可以使用以下查询
var filter = testTable.AsEnumerable().
Where(x => x.Field<string>("City") == "HongKong");
使用LINQ to DataSets,您可以执行以下操作:
DataTable table;
var rows =
from row in table.AsEnumerable()
where row.Field<string>("City") == "Hongkong"
select row;