using System.Collections; namespace Connected.Expressions.Translation; internal sealed class Grouping : IGrouping { public Grouping(TKey key, IEnumerable group) { Key = key; Group = group; } public TKey Key { get; } private IEnumerable Group { get; set; } public IEnumerator GetEnumerator() { if (!(Group is List)) Group = Group.ToList(); return Group.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return Group.GetEnumerator(); } }