1

I have a DataTable. I would like to filter DataRows where City = "Hongkong".

How to apply LINQ against DataRow?

4

3 回答 3

1
 var result = dr.Where(r => r.Field<string>("City") == "Hongkong");
于 2013-06-15T18:00:59.653 回答
1

您可以使用以下查询

var filter = testTable.AsEnumerable().
                       Where(x => x.Field<string>("City") == "HongKong");
于 2013-06-15T18:01:40.453 回答
0

使用LINQ to DataSets,您可以执行以下操作:

DataTable table;

var rows =
    from row in table.AsEnumerable()
    where row.Field<string>("City") == "Hongkong"
    select row;
于 2013-06-15T18:02:39.760 回答