System.Data.ExprException.TypeMismatch C# (CSharp) Method

TypeMismatch() public static method

public static TypeMismatch ( string expr ) : Exception
expr string
return Exception
        public static Exception TypeMismatch(string expr)
        {
            return _Eval(SR.Format(SR.Expr_TypeMismatch, expr));
        }

Usage Example

示例#1
0
        private object EvalUnaryOp(int op, object vl)
        {
            object value = DBNull.Value;

            if (DataExpression.IsUnknown(vl))
            {
                return(DBNull.Value);
            }

            switch (op)
            {
            case Operators.Noop:
                return(vl);

            case Operators.UnaryPlus:
                if (ExpressionNode.IsNumeric(vl.GetType()))
                {
                    return(vl);
                }
                throw ExprException.TypeMismatch(this.ToString());

            case Operators.Negative:
                // the have to be better way for doing this..
                if (ExpressionNode.IsNumeric(vl.GetType()))
                {
                    if (vl is byte)
                    {
                        value = -(Byte)vl;
                    }
                    else if (vl is Int16)
                    {
                        value = -(Int16)vl;
                    }
                    else if (vl is Int32)
                    {
                        value = -(Int32)vl;
                    }
                    else if (vl is Int64)
                    {
                        value = -(Int64)vl;
                    }
                    else if (vl is Single)
                    {
                        value = -(Single)vl;
                    }
                    else if (vl is Double)
                    {
                        value = -(Double)vl;
                    }
                    else if (vl is Decimal)
                    {
                        value = -(Decimal)vl;
                    }
                    else
                    {
                        Debug.Assert(false, "Missing a type conversion " + vl.GetType().FullName);
                        value = DBNull.Value;
                    }
                    return(value);
                }

                throw ExprException.TypeMismatch(this.ToString());

            case Operators.Not:
                if (DataExpression.ToBoolean(vl) != false)
                {
                    return(false);
                }
                return(true);

            default:
                throw ExprException.UnsupportedOperator(op);
            }
        }
All Usage Examples Of System.Data.ExprException::TypeMismatch