CodAri CodAri - 1 month ago 24
ASP.NET (C#) Question

Documentdb .net decimal leading zeros

I'm saving information to Azure Documentdb with asp.net code.
When I save information Documentdb cuts endind zeros from value.

If the price has been 150.90 I find 150.9 from Documentdb.

Is this normal? Should I do some sort of conversion back or is it only solution to start using string?

Answer

In JavaScript there is only one numeric type, Number which covers both Integers and Reals. Since DocumentDB is based upon JavaScript Object Notation (JSON) it suffers from the same limitation. I assume that if you are using a Decimal type, you must have some reason. Maybe it's money you are storing? If so, then your safest option is to use a string in DocumentDB.