DataTable Linq查询 1.查询DataRow IEnumerable<DataRow> q1 = from r in dt.AsEnumerable() == select r; 2.查询某个字段 var query2 = from pl in dt.AsEnumerable( ) select pl.Field<string>("Name"); 3.group by var query = from r in dt.AsEnumerable() g…
DataTable通过dt.AsEnumerable()方法转换可用Linq查询,反之,Linq也可以转化为DataTableDataTable newDt = query1.CopyToDataTable<DataRow>();var query1 = from stu in dtStu.AsEnumerable() from score in dtScore.AsEnumerable() where stu.Field<int>("ScoreID&q…
datatable我们是经常使用到的,但是需要对数据进行分组,具体代码如下: var result = dt.AsEnumerable().GroupBy(f => new { type = f.Field<string>("type"), value = f.Field<string>("value"), site_id = f.Field<string>("site_id") }).Select(f…
关于datatable datarow DataTable paraval = GetParaVal(DateCondition, strUrl, Page, RowPage, iYearMonthNow, 2); var query = from t in paraval.AsEnumerable() //datatable 和linq转换 group t by new { t1 = t.Field<string>("InsKind") } into m select n…