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); }
internal static bool IsNumeric(StorageType type) { if (!ExpressionNode.IsFloat(type)) { return(ExpressionNode.IsInteger(type)); } return(true); }
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); }