Пример #1
0
         public static PivotTable<TRow, TColumn, TValue> ToPivot<TItem, TRow, TColumn, TValue>(
             this IEnumerable<TItem> source,
             Func<TItem, TRow> rowSelector,
             Func<TItem, TColumn> colSelector,
             Func<IEnumerable<TItem>, TValue> aggregatFunc
         )
             where TRow : IComparable, IEquatable<TRow>
             where TColumn : IComparable, IEquatable<TColumn>
         {
             var dic = source
                 .GroupBy(rowSelector)
                 .ToDictionary(x => x.Key, x => x.GroupBy(colSelector).ToDictionary(y => y.Key, y => aggregatFunc(y)));
 
             return PivotTable.Create(dic);
         }