sdk/dotnet/src/Microsoft.Datasync.Client/Query/OData/TableLookupExtensions.cs
/// <summary>
/// Converts a constant to the value of the OData representation.
/// </summary>
/// <param name="node">The <see cref="ConstantNode"/> to convert.</param>
/// <returns>The OData representation of the constant node value.</returns>
Converts a constant to the value of the OData representation.
Converts a constant to the value of the OData representation .
internal static string ToODataString(this ConstantNode node)
        {
            object value = node.Value;
            switch (value.GetConstantType())
            {
                case ConstantType.Null:
                    return "null";
                case ConstantType.Boolean:
                    return ((bool)value).ToString().ToLower();
                case ConstantType.Byte:
                    return $"{value:X2}";
                case ConstantType.Character:
                    string ch = (char)value == '\'' ? "''" : ((char)value).ToString();
                    return $"'{ch}'";
                case ConstantType.Decimal:
                    return $"{value}M";
                case ConstantType.Double:
                    string d = ((double)value).ToString("G");
                    return (d.Contains("E") || d.Contains(".")) ? d : $"{d}.0";
                case ConstantType.Float:
                    return $"{value}f";
                case ConstantType.Int:
                case ConstantType.Short:
                case ConstantType.UnsignedShort:
                case ConstantType.SignedByte:
                    return $"{value}";
                case ConstantType.Long:
                case ConstantType.UnsignedInt:
                case ConstantType.UnsignedLong:
                    return $"{value}L";
                default:
                    return EdmTypeSupport.ToODataString(value) ?? $"'{value.ToString().Replace("'", "''")}'";
            }
        }
internal static string ToODataString ( this ConstantNode node ) { object value = node . Value ; switch ( value . GetConstantType ( ) ) { case ConstantType . Null : return " " ; case ConstantType . Boolean : return ( ( bool ) value ) . ToString ( ) . ToLower ( ) ; case ConstantType . Byte : return $" { value : } " ; case ConstantType . Character : string ch = ( char ) value == ' \' ' ? " " : ( ( char ) value ) . ToString ( ) ; return $" ' { ch } ' " ; case ConstantType . Decimal : return $" { value } M " ; case ConstantType . Double : string d = ( ( double ) value ) . ToString ( " " ) ; return ( d . Contains ( " " ) || d . Contains ( " " ) ) ? d : $" { d } .0 " ; case ConstantType . Float : return $" { value } f " ; case ConstantType . Int : case ConstantType . Short : case ConstantType . UnsignedShort : case ConstantType . SignedByte : return $" { value } " ; case ConstantType . Long : case ConstantType . UnsignedInt : case ConstantType . UnsignedLong : return $" { value } L " ; default : return EdmTypeSupport . ToODataString ( value ) ?? $" ' { value . ToString ( ) . Replace ( " " , " " ) } ' " ; } }
Converts a constant to the value of the OData representation.
Converts a constant to the value of the OData representation .
The OData representation of the constant node value.
The OData representation of the constant node value .
ConstantNode
this
node
The  to convert.
The to convert .