DataTable分组

DataTable dt= dbhelp.Query(sql).Tables[0];
IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy<DataRow, string>(dr => dr["A"].ToString());//按A分组
foreach (IGrouping<string, DataRow> ig in result)
{
string s = ig.Key; A
int i= ig.Count(); A类型笔数
}

  



猜你喜欢

转载自www.cnblogs.com/edukong/p/10871301.html
今日推荐