LINQ系列:LINQ to DataSet的DataView操作

libingql發表於2014-10-23

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();

相關文章