C# Linq group by 多个字段
程序员文章站
2022-07-04 10:19:48
...
var result = (
from meta in metaErrorInfos
group meta by new
{
meta.SchemaInfoId,
meta.SchemaName
} into t
select new
{
SchemaInfoId = t.Key.SchemaInfoId,
SchemaName = t.Key.SchemaName,
Tec = t.Max(x => x.Tec),
Line = t.Max(x => x.Line),
MailTo = t.Max(x => x.MailTo),
Version = t.Max(x => x.Version),
CategoryName = t.Max(x => x.CategoryName),
ErrorItemTotalCount = t.Count(),
ErrorItems = t.GroupBy(x => x.ErrorItem).Select(x => new { name = x.Key, repeat = x.Count() }).ToList(),
MetaPath = t.Select(a => a.MetaPath).ToList()
}).ToList();
上一篇: C# linq group by的运用
下一篇: EventBus3 使用方法