LINQ C# 中的分组和字符串连接

Mag*_*n V -3 c# linq lambda c#-4.0

我是 C# linq 新手。

我的数据结果如下,

Id | Name   | Code
1  | Go     | GOS
1  | RES    | RECSO
1  | ICS    | ICSO 
2  | Go     | GOS
2  | ICS    | ICSO 
Run Code Online (Sandbox Code Playgroud)

我想要的结果如下,

Id | Name     | Code
1, Go,RES,ICS | GOS,RECSO,ICSO 
2, Go,ICS     | GOS,ICSO
Run Code Online (Sandbox Code Playgroud)

有人可以用优化的方式为此提供 linq 查询吗,因为我有大数据集。

提前致谢

use*_*861 7

var result = data.GroupBy(g => g.Id)
.Select(s => new {
    Id = s.Key,
    Name = string.Join(",", s.Select(ss => ss.Name)),
    Code = string.Join(",", s.Select(ss => ss.Code)),
});
Run Code Online (Sandbox Code Playgroud)