集合分组、求和、合并字段

var newList = list.GroupBy(s => s.userId).Select(s => new person { userId = s.Key, weight = s.Sum(s => s.weight),desc=String.Join("", s.Select(a => a.desc).ToList()) }).ToList();

 

posted @ 2023-02-17 17:30  明哲保身  阅读(31)  评论(0编辑  收藏  举报