public static DbValue Average(this RowCollection rowCollection, string column)
        {
            var sum   = rowCollection.AggregateByColumn(column, DbValueMath.Sum);
            var count = rowCollection.Count(row => row.Cells[column] != null && row.Cells[column].Value != null);

            if (sum.Value is long)
            {
                return((double)(long)sum.Value / count);
            }
            if (sum.Value is decimal)
            {
                return((decimal)sum.Value / count);
            }
            if (sum.Value is double)
            {
                return((double)sum.Value / count);
            }
            throw new InvalidTypeException(sum.Type, Resources.CannotAverageType.FormatExt(sum.Type));
        }
 public static DbValue Min(this RowCollection rowCollection, string column)
 {
     return(rowCollection.AggregateByColumn(column, (min, current) =>
                                            (min == null || DbValueMath.Compare(current, min, Comparison.LessThan)) ? current : min));
 }
 public static DbValue Max(this RowCollection rowCollection, string column)
 {
     return(rowCollection.AggregateByColumn(column, (max, current) =>
                                            (max == null || DbValueMath.Compare(current, max, Comparison.GreaterThan)) ? current : max));
 }
 public static DbValue Sum(this RowCollection rowCollection, string column)
 {
     return(rowCollection.AggregateByColumn(column, DbValueMath.Sum));
 }