LINQ系列:LINQ to DataSet的DataView操作

1. 创建DataView

EnumerableRowCollection<DataRow> expr = from p in products.AsEnumerable()
                                        orderby p.Field<int>("SortOrder")
                                        select p;
DataView view = expr.AsDataView();

2. DataView查询

EnumerableRowCollection<DataRow> expr = from p in products.AsEnumerable()
                                    where p.Field<decimal>("UnitPrice") > 10m 
                                        && p.Field<string>("ProductName").StartsWith("LINQ")
                                    select p;
DataView view = expr.AsDataView();

你可能感兴趣的:(LINQ)