Linq分组
DataTable dt=SqlHelp.DataSource(strsql);
var vardt = from t in dt.AsEnumerable()
group t by t.Field<string>("sclass") into g
where g.Count()>1
select g;
var query = from t in dt.AsEnumerable()
group t by
new {
t1 = t.Field<string>("sclass")
} into m
where m.Count()>1
select new
{
//flightno = m.First().Field<string>("sclass"),
sno =m.Sum(t=>Convert.ToInt32(t.Field<string>("sno"))),
sname = m.First().Field<string>("sname"),
ssex = m.First().Field<string>("ssex"),
sbirthday = m.First().Field<DateTime>("sbirthday"),
sclass = m.First().Field<string>("sclass")
};
//var vardt = from t in dt.AsEnumerable()
// where t.Field<string>("sclass").ToString() == "95031"
// select new
// {
// sno = t.Field<string>("sno"),
// sname = t.Field<string>("sname"),
// ssex = t.Field<string>("ssex"),
// sbirthday = t.Field<DateTime>("sbirthday"),
// sclass = t.Field<string>("sclass")
// };