C# Linq 分组后拼接字符串
分组后将Name以“,”分隔进行拼接
var result = _dataRepository.GetAll().GroupBy(g => g.Id) .Select(s => new { Id = s.Key, Name = string.Join(",", s.Select(d => d.Name)), });
分组后将Name以“,”分隔进行拼接
var result = _dataRepository.GetAll().GroupBy(g => g.Id) .Select(s => new { Id = s.Key, Name = string.Join(",", s.Select(d => d.Name)), });