public override object Aggregate(int[] records, AggregateType kind)
{
bool hasData = false;
try
{
switch (kind)
{
case AggregateType.Min:
char min = char.MaxValue;
for (int i = 0; i < records.Length; i++)
{
int record = records[i];
if (IsNull(record))
continue;
min = (_values[record] < min) ? _values[record] : min;
hasData = true;
}
if (hasData)
{
return min;
}
return _nullValue;
case AggregateType.Max:
char max = char.MinValue;
for (int i = 0; i < records.Length; i++)
{
int record = records[i];
if (IsNull(record))
continue;
max = (_values[record] > max) ? _values[record] : max;
hasData = true;
}
if (hasData)
{
return max;
}
return _nullValue;
case AggregateType.First:
if (records.Length > 0)
{
return _values[records[0]];
}
return null;
case AggregateType.Count:
return base.Aggregate(records, kind);
}
}
catch (OverflowException)
{
throw ExprException.Overflow(typeof(char));
}
throw ExceptionBuilder.AggregateException(kind, _dataType);
}