static object Sum(IEnumerable data , ExpressionNode node , object context , string exp , out int count , out StorageType type) { count = 0; type = StorageType.Empty; //if (0 == view.Data.Count) // return 0; object value = 0; foreach (object value2 in Aggregates.NotNullValue(data, node, context)) { count++; if (type == StorageType.Empty) { type = DataStorageHelper.GetStorageType(value2.GetType()); if (count == 1 && type == StorageType.String) { value = 0m; } if (!(type == StorageType.SqlDecimal || type == StorageType.SqlMoney || type == StorageType.Decimal || type == StorageType.Single)) { if (ExpressionNode.IsUnsignedSql(type)) { type = StorageType.UInt64; } if (ExpressionNode.IsInteger(type)) { type = StorageType.Int64; } else if (ExpressionNode.IsIntegerSql(type)) { type = StorageType.SqlInt64; } else if (ExpressionNode.IsFloat(type)) { type = StorageType.Double; } else if (ExpressionNode.IsFloatSql(type)) { type = StorageType.SqlDouble; } } } value = Add(value, value2, type); } return(value); }
public static object First(FunctionContext context, IEnumerable data, ExpressionNode node) { foreach (object value in Aggregates.NotNullValue(data, node, context.GlobalContext)) { return(value); } return(null); }
public static object Last(FunctionContext context, IEnumerable data, ExpressionNode node) { object obj1 = (object)null; foreach (object obj2 in Aggregates.NotNullValue(data, node, context.GlobalContext)) { obj1 = obj2; } return(obj1); }
public static object First(FunctionContext context, IEnumerable data, ExpressionNode node) { using (IEnumerator <object> enumerator = Aggregates.NotNullValue(data, node, context.GlobalContext).GetEnumerator()) { if (enumerator.MoveNext()) { return(enumerator.Current); } } return((object)null); }
public static object Last(FunctionContext context, IEnumerable data, ExpressionNode node) { object value = null; foreach (object value1 in Aggregates.NotNullValue(data, node, context.GlobalContext)) { value = value1; } return(value); }
private static object Sum( IEnumerable data, ExpressionNode node, object context, string exp, out int count, out StorageType type) { count = 0; type = StorageType.Empty; object obj1 = (object)0; foreach (object obj2 in Aggregates.NotNullValue(data, node, context)) { ++count; if (type == StorageType.Empty) { type = DataStorageHelper.GetStorageType(obj2.GetType()); if (count == 1 && type == StorageType.String) { obj1 = (object)new Decimal(0); } if (type != StorageType.SqlDecimal && type != StorageType.SqlMoney && (type != StorageType.Decimal && type != StorageType.Single)) { if (ExpressionNode.IsUnsignedSql(type)) { type = StorageType.UInt64; } if (ExpressionNode.IsInteger(type)) { type = StorageType.Int64; } else if (ExpressionNode.IsIntegerSql(type)) { type = StorageType.SqlInt64; } else if (ExpressionNode.IsFloat(type)) { type = StorageType.Double; } else if (ExpressionNode.IsFloatSql(type)) { type = StorageType.SqlDouble; } } } obj1 = Aggregates.Add(obj1, obj2, type); } return(obj1); }
public static object Min(FunctionContext context, IEnumerable data, ExpressionNode node) { object obj1 = (object)null; foreach (object obj2 in Aggregates.NotNullValue(data, node, context.GlobalContext)) { if (obj1 == null) { obj1 = obj2; } else if (0 < Aggregates.Compare(obj1, obj2, context, nameof(Min))) { obj1 = obj2; } } return(obj1); }
public static object Min(FunctionContext context, IEnumerable data, ExpressionNode node) { object value = null; foreach (object value2 in Aggregates.NotNullValue(data, node, context.GlobalContext)) { if (null == value) { value = value2; } else if (0 < Aggregates.Compare(value, value2, context, "Min")) { value = value2; } } return(value); }
public static object StDev(FunctionContext context, IEnumerable data, ExpressionNode node) { IList <Decimal> numList = (IList <Decimal>) new List <Decimal>(); Decimal num1 = new Decimal(0); foreach (object obj in Aggregates.NotNullValue(data, node, (object)context)) { StorageType storageType = DataStorageHelper.GetStorageType(obj.GetType()); if (ExpressionNode.IsNumeric(storageType)) { Decimal num2 = Convert.ToDecimal(obj); num1 += num2; numList.Add(num2); } else { if (storageType != StorageType.String && storageType != StorageType.SqlString) { throw new NotSupportedException("Standard deviation is not supported for type " + storageType.ToString()); } Decimal result; if (Decimal.TryParse(obj.ToString(), out result)) { num1 += result; numList.Add(result); } } } if (numList.Count == 0) { return((object)0); } Decimal num3 = num1 / (Decimal)numList.Count; Decimal num4 = new Decimal(0); foreach (Decimal num2 in (IEnumerable <Decimal>)numList) { Decimal num5 = num2 - num3; Decimal num6 = num5 * num5; num4 += num6; } return((object)Aggregates.DecimalSqrt(num4 / (Decimal)numList.Count, new Decimal?())); }