none
ODataUriUtils.ConvertToUriLiteral(3.5) returns "3.5M" RRS feed

Answers

  • Hey Dave,

    We are building a value based on the OData spec that ensures that the type you specify is written out.

    If you look at this page here

    http://www.odata.org/media/30002/OData%20ABNF.html

    and search for decimal, here is the ABNF

        decimal = sign 1*29DIGIT ["." 1*29DIGIT] ("M"/"m")

    M or m is the way that we identify a decimal from a double. In C# if you write "var decValue = 3.5M" the compiler will interpret this as a decimal because of the M. We followed the C# semantics for disambiguating between different numbers. Double for instance could have a D or d.

    Thanks,

    Chris Robinson - WCF Data Services


    This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by DavidThi808 Thursday, January 10, 2013 11:42 PM
    Thursday, January 10, 2013 10:23 PM
    Moderator
  • Yes, you need to use the M (if you want the literal to mean decimal, note that there is some amount of implicit conversion going on, so sometimes it's not necessary). And no, do not put quotes around it in the URL.

    Thanks,


    Vitek Karas [MSFT]

    • Marked as answer by DavidThi808 Thursday, January 10, 2013 11:42 PM
    Thursday, January 10, 2013 11:23 PM
    Moderator

All replies

  • Hey Dave,

    We are building a value based on the OData spec that ensures that the type you specify is written out.

    If you look at this page here

    http://www.odata.org/media/30002/OData%20ABNF.html

    and search for decimal, here is the ABNF

        decimal = sign 1*29DIGIT ["." 1*29DIGIT] ("M"/"m")

    M or m is the way that we identify a decimal from a double. In C# if you write "var decValue = 3.5M" the compiler will interpret this as a decimal because of the M. We followed the C# semantics for disambiguating between different numbers. Double for instance could have a D or d.

    Thanks,

    Chris Robinson - WCF Data Services


    This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by DavidThi808 Thursday, January 10, 2013 11:42 PM
    Thursday, January 10, 2013 10:23 PM
    Moderator
  • Oh, ok. That makes sense.

    So when I do a filter with a decimal, do I need to put 3.5M in quotes because of the M? Or is no quotes fine (or required)?

    thanks - dave


    Who will win The Windward International Collegiate Programming Championships?

    Thursday, January 10, 2013 11:04 PM
  • Yes, you need to use the M (if you want the literal to mean decimal, note that there is some amount of implicit conversion going on, so sometimes it's not necessary). And no, do not put quotes around it in the URL.

    Thanks,


    Vitek Karas [MSFT]

    • Marked as answer by DavidThi808 Thursday, January 10, 2013 11:42 PM
    Thursday, January 10, 2013 11:23 PM
    Moderator