日期:2014-05-17 浏览次数:20691 次
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("产品id"));
dt.Columns.Add(new DataColumn("颜色"));
dt.Columns.Add(new DataColumn("尺寸"));
dt.Columns.Add(new DataColumn("型号"));
dt.Rows.Add(new object[] { 1, "红色", "5*6", "型号1" });
dt.Rows.Add(new object[] { 1, "红色", "10*10", "型号2" });
dt.Rows.Add(new object[] { 1, "黑色", "5*6", "型号1" });
dt.Rows.Add(new object[] { 1, "白色", "10*10", "型号2" });
var dtquery = from d in dt.AsEnumerable()
group d by d.Field<string>("产品id") into temp