コード例 #1
0
ファイル: Aggregates.cs プロジェクト: configare/hispeed
        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);
        }
コード例 #2
0
 internal static bool IsSignedSql(StorageType type)
 {
     if (type != StorageType.Int16 && type != StorageType.Int32 && (type != StorageType.Int64 && type != StorageType.SByte) && (type != StorageType.SqlInt64 && type != StorageType.SqlInt32 && type != StorageType.SqlInt16))
     {
         return(ExpressionNode.IsFloatSql(type));
     }
     return(true);
 }
コード例 #3
0
 internal static bool IsNumericSql(StorageType type)
 {
     if (!ExpressionNode.IsFloatSql(type))
     {
         return(ExpressionNode.IsIntegerSql(type));
     }
     return(true);
 }
コード例 #4
0
ファイル: Aggregates.cs プロジェクト: RichardHaggard/BDC
        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);
        }