internal DbArithmeticExpression(DbExpressionKind kind, TypeUsage numericResultType, DbExpressionList args)
            : base(kind, numericResultType)
        {
            Debug.Assert(TypeSemantics.IsNumericType(numericResultType), "DbArithmeticExpression result type must be numeric");

            Debug.Assert(
                DbExpressionKind.Divide == kind ||
                DbExpressionKind.Minus == kind ||
                DbExpressionKind.Modulo == kind ||
                DbExpressionKind.Multiply == kind ||
                DbExpressionKind.Plus == kind ||
                DbExpressionKind.UnaryMinus == kind,
                "Invalid DbExpressionKind used in DbArithmeticExpression: " + Enum.GetName(typeof(DbExpressionKind), kind)
                );

            Debug.Assert(args != null, "DbArithmeticExpression arguments cannot be null");

            Debug.Assert(
                (DbExpressionKind.UnaryMinus == kind && 1 == args.Count) ||
                2 == args.Count,
                "Incorrect number of arguments specified to DbArithmeticExpression"
                );

            this._args = args;
        }
Esempio n. 2
0
 internal static bool SupportsCastToString(TypeUsage typeUsage)
 {
     return(TypeSemantics.IsPrimitiveType(typeUsage, PrimitiveTypeKind.String) ||
            TypeSemantics.IsNumericType(typeUsage) ||
            TypeSemantics.IsBooleanType(typeUsage) ||
            TypeSemantics.IsPrimitiveType(typeUsage, PrimitiveTypeKind.DateTime) ||
            TypeSemantics.IsPrimitiveType(typeUsage, PrimitiveTypeKind.DateTimeOffset) ||
            TypeSemantics.IsPrimitiveType(typeUsage, PrimitiveTypeKind.Time) ||
            TypeSemantics.IsPrimitiveType(typeUsage, PrimitiveTypeKind.Guid));
 }