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类型笔数 }
原文:https://www.cnblogs.com/edukong/p/10871301.html