首页 > 代码库 > DataTable/Array Linq查询

DataTable/Array Linq查询

DataTable Linq查询

1.查询DataRow

1 IEnumerable<DataRow> q1 = from r in dt.AsEnumerable()2                                       where r.Field<int>("ID") % 2 == 03                                       select r;

2.查询某个字段

1 var query2 =2         from pl in dt.AsEnumerable( )3         select pl.Field<string>("Name");

 

Array Linq查询

1 int[] values = { 2,9,5,0,3,7,1,4,8,5};  2             var filtered =  3                 from value in values  4                 where value > 4  5                 select value;  

 

DataTable/Array Linq查询