我在 C# 中定义了以下 DTO 对象:
public class Record
{
public List<EventType> EventTypes { get; set; }
}
并且在填充 List<Record> 而 EventType 被定义为枚举之后
public Enum EventType {
UNLOCK = 1,
LOCK = 2
}
现在我想从记录列表中制作一个类似于以下的报告:
count Name
===== ======
3 UNLOCK
1 LOCK
...通过使用(很可能是LINQ group by)。列出此列表的首选方法是什么?我假设我将不得不制作另一个 DTO 来保存该数据。