Avkash Chauhan's Blog

Windows Azure, Windows 8, Cloud Computing, Big Data and Hadoop: All together at one place.. One problem, One solution at One time...

How you can store decimal data in Windows Azure Table Storage?

How you can store decimal data in Windows Azure Table Storage?

Rate This
  • Comments 1

At this point Windows Azure Table Storage does not support natively storing decimal point data as described in the below supported property types which is a subset of data types defined by the ADO.NET Data Services specification:

 

ADO.NET Data Services type

Common Language Runtime type

Details

Edm.Binary

byte[]

An array of bytes up to 64 KB in size.

Edm.Boolean

bool

A Boolean value.

Edm.DateTime

DateTime

A 64-bit value expressed as Coordinated Universal Time (UTC). The supported DateTime range begins from 12:00 midnight, January 1, 1601 A.D. (C.E.), UTC. The range ends at December 31, 9999.

Edm.Double

double

A 64-bit floating point value.

Edm.Guid

Guid

A 128-bit globally unique identifier.

Edm.Int32

Int32 or int

A 32-bit integer.

Edm.Int64

Int64 or long

A 64-bit integer.

Edm.String

String

A UTF-16-encoded value. String values may be up to 64 KB in size. (Default Value)

 

While you can store your decimal data as string in the table and in your code you can use client library based serializer which supports decimal. So you can in effect use decimal by just changing the data type to PrimitiveTypeKind.String in your ReadingWritingEntityEvent handler.

 

Using custom attribute the solution becomes fairly convenient. For example, the entity classes just use the following code to get decimal data:


        [EntityDataType(PrimitiveTypeKind.String)]

        public decimal Quantity { get; set; }

 

The above code just works fine with string type data but doesn’t work for other unsupported types like enums or TimeSpan.

Thanks to Windows Azure Product team for providing this information.

 

Leave a Comment
  • Please add 4 and 8 and type the answer here:
  • Post
  • Lucifure Stash is an alternate Azure table storage client, which supports arrays, enumerations, large data > 64KB, serialization, public and private properties and fields and more. It supports morphing capabilities such that you can easily store and retrieve any data type by transforming it into one of the Azure table storage supported datatypes.

    You can download Lucifure Stash, from http://www.lucifure.com via NuGet.

Page 1 of 1 (1 items)