Here we are with another discovery to be aware of when you plan to go on the cloud or more in general to use some NoSQL engine: System.Decimal is not supported.

We are making a test drive of 3 NoSQL engines:

  • Azure Table Storage: key – value
  • Amazon SimpleDB: key – value
  • MongoDB: document based

All of them do not support System.Decimal, therefore if you want to store currencies, exchange rates, large amounts with decimal digits, you’ll have to find a workaround. For the POC we have decided to go for double type, but during communications with real POS terminals ISO8583 protocol is used. In it amounts are divided in 2 separate parts:

  • Amount: total amount with integer part followed by mantissa without separatore (i.e. 100,91 becomes 10091)
  • MinorUnit: number of decimal digits (i.e. considering 100,91 it is 2)

Here follows a short summary table of types supported by the 3 engines:

Tipo Azure Table Storage Amazon SimpleDB MongoDB
byte[] X   X
bool X   X
DateTime X   X
double X   X
Guid X   X
Int32 o int X   X
Int64 o long X   X
String X X (max 1024 bytes) X
regex     X

Amazon has decided to use a simpler technical implementation for its NoSQL on the cloud, but this lead to some limitations: values are all stored as strings with a maximum size limited to 1024 bytes and comparison is lexicographic, therefore for SimpleDB 10 is before 2, so developers have to do some additional work (losing a bit of performance on application code) to handle numeric values: http://aws.amazon.com/articles/1232

Note: it’s always possible to implement an event handler to be called during reading/writing operation against NoSQL above, to be used to convert Decimal to string and viceversa.

Stay tuned for the next stop!