System.Data.Common.SqlStringStorage.Aggregate C# (CSharp) Method

Aggregate() public method

public Aggregate ( int recordNos, AggregateType kind ) : object
recordNos int
kind AggregateType
return object
        public override object Aggregate(int[] recordNos, AggregateType kind)
        {
            try
            {
                int i;
                switch (kind)
                {
                    case AggregateType.Min:
                        int min = -1;
                        for (i = 0; i < recordNos.Length; i++)
                        {
                            if (IsNull(recordNos[i]))
                                continue;
                            min = recordNos[i];
                            break;
                        }
                        if (min >= 0)
                        {
                            for (i = i + 1; i < recordNos.Length; i++)
                            {
                                if (IsNull(recordNos[i]))
                                    continue;
                                if (Compare(min, recordNos[i]) > 0)
                                {
                                    min = recordNos[i];
                                }
                            }
                            return Get(min);
                        }
                        return _nullValue;


                    case AggregateType.Max:
                        int max = -1;
                        for (i = 0; i < recordNos.Length; i++)
                        {
                            if (IsNull(recordNos[i]))
                                continue;
                            max = recordNos[i];
                            break;
                        }
                        if (max >= 0)
                        {
                            for (i = i + 1; i < recordNos.Length; i++)
                            {
                                if (Compare(max, recordNos[i]) < 0)
                                {
                                    max = recordNos[i];
                                }
                            }
                            return Get(max);
                        }
                        return _nullValue;

                    case AggregateType.Count:
                        int count = 0;
                        for (i = 0; i < recordNos.Length; i++)
                        {
                            if (!IsNull(recordNos[i]))
                                count++;
                        }
                        return count;
                }
            }
            catch (OverflowException)
            {
                throw ExprException.Overflow(typeof(SqlString));
            }
            throw ExceptionBuilder.AggregateException(kind, _dataType);
        }