src/Shared/EntityFramework/Core/Common/EntitySql/AST/Literal.cs
// <summary>
// Performs conversion of numeric strings that have no type suffix hint.
// </summary>
Performs conversion of numeric strings that have no type suffix hint.
Performs conversion of numeric strings that have no type suffix hint .
private static object DefaultNumericConversion(string numericString, ErrorContext errCtx)
        {
            if (-1
                != numericString.IndexOfAny(_floatTokens))
            {
                Double value;
                if (!Double.TryParse(numericString, NumberStyles.Float, CultureInfo.InvariantCulture, out value))
                {
                    var message = Strings.CannotConvertNumericLiteral(numericString, "double");
                    throw EntitySqlException.Create(errCtx, message, null);
                }
                return value;
            }
            else
            {
                Int32 int32Value;
                if (Int32.TryParse(numericString, NumberStyles.Integer, CultureInfo.InvariantCulture, out int32Value))
                {
                    return int32Value;
                }
                Int64 int64Value;
                if (!Int64.TryParse(numericString, NumberStyles.Integer, CultureInfo.InvariantCulture, out int64Value))
                {
                    var message = Strings.CannotConvertNumericLiteral(numericString, "long");
                    throw EntitySqlException.Create(errCtx, message, null);
                }
                return int64Value;
            }
        }
private static object DefaultNumericConversion ( string numericString , ErrorContext errCtx ) { if ( - 1 != numericString . IndexOfAny ( _floatTokens ) ) { Double value ; if ( ! Double . TryParse ( numericString , NumberStyles . Float , CultureInfo . InvariantCulture , out value ) ) { var message = Strings . CannotConvertNumericLiteral ( numericString , " " ) ; throw EntitySqlException . Create ( errCtx , message , null ) ; } return value ; } else { Int32 int32Value ; if ( Int32 . TryParse ( numericString , NumberStyles . Integer , CultureInfo . InvariantCulture , out int32Value ) ) { return int32Value ; } Int64 int64Value ; if ( ! Int64 . TryParse ( numericString , NumberStyles . Integer , CultureInfo . InvariantCulture , out int64Value ) ) { var message = Strings . CannotConvertNumericLiteral ( numericString , " " ) ; throw EntitySqlException . Create ( errCtx , message , null ) ; } return int64Value ; } }
Performs conversion of numeric strings that have no type suffix hint.
Performs conversion of numeric strings that have no type suffix hint .
numericString
string
errCtx
ErrorContext