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

DatavalueConvertion() public static method

public static DatavalueConvertion ( object value, Type type, Exception innerException ) : Exception
value object
type System.Type
innerException System.Exception
return System.Exception
        public static Exception DatavalueConvertion(object value, Type type, Exception innerException)
        {
            return _Eval(SR.Format(SR.Expr_DatavalueConvertion, value.ToString(), type.ToString()), innerException);
        }

Usage Example

示例#1
0
        internal static bool ToBoolean(object value)
        {
            if (IsUnknown(value))
            {
                return(false);
            }
            if (value is bool)
            {
                return((bool)value);
            }
            if (value is SqlBoolean)
            {
                return(((SqlBoolean)value).IsTrue);
            }
            //check for SqlString is not added, value for true and false should be given with String, not with SqlString
            if (value is string)
            {
                try
                {
                    return(bool.Parse((string)value));
                }
                catch (Exception e) when(ADP.IsCatchableExceptionType(e))
                {
                    ExceptionBuilder.TraceExceptionForCapture(e);
                    throw ExprException.DatavalueConvertion(value, typeof(bool), e);
                }
            }

            throw ExprException.DatavalueConvertion(value, typeof(bool), null);
        }
All Usage Examples Of System.Data.ExprException::DatavalueConvertion