日期:2014-05-20 浏览次数:20913 次
var data = new List<Product> { new Product{Maker="耐克", Name="篮球鞋", Location="上海"}, new Product{Maker="耐克", Name="篮球鞋", Location="北京"}, new Product{Maker="耐克", Name="足球鞋", Location="上海"}, new Product{Maker="阿迪达斯", Name="篮球鞋", Location="上海"}, }; var result = (from p in data group p by new { p.Maker, p.Location } into g select new Product { Maker = g.Key.Maker, Location = g.Key.Location, Name = string.Join("+", g.Select(p => p.Name).ToArray()) }).ToList();