Unable to save single precision floating data type in Azure table storage
-
mardi 3 avril 2012 16:30
I have defined a table storage entity with single precision floating data type as follows:
public class MyEntity : TableServiceEntity {
public float value { get; set; }
<other properties>
}I saw following error while trying to save batch of the entities:
System.Net.WebException was caught
Message=The remote server returned an error: (400) Bad Request.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.Data.Services.Client.DataServiceContext.SaveResult.BatchRequest(Boolean replaceOnUpdate)
at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
<my code stack>A quick search on Internet yielded no meaningful result for such an exception with Azure table storage. I fired fiddler to dig deeper. I noticed following *cryptic* error message in response to the batch request:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>InvalidInput</code>
<message xml:lang="en-US">One of the request inputs is not valid.</message>
</error>This error message did not help in any way to reach root cause of the exception. Fortunately, I stumbled across this(http://msdn.microsoft.com/en-us/library/windowsazure/dd179338.aspx) page that *does not list* 'float' or System.Single as supported data type.
Ideally, I would expect storage client library to report that 'float' data type is not supported. AFAIK, the library does report such error for enums. Is it a known issue that storage client library does not tell about unsupported 'float' data type?
On sideline, the REST response in this case is of almost no help. Please make is helpful to developers. And also the exception thrown by storage client library while saving entities with 'float' data could be more elaborate.
Thanks in advance.
~Zendu
Toutes les réponses
-
mardi 3 avril 2012 16:55
Azure table storage supports 8 data types and single/float is not one of them. However it can be easily/efficiently supported by casting to double. Yes, the error reporting could be more helpful.
I have written an alternate Azure table storage client, Lucifure Stash, which supports large data columns > 64K, arrays, enums, serialization, public and private properties and fields and more. It also supports attribute decorated morphing from one type to anther and may work for you in this case. It is available free for personal use. You can get it at http://www.lucifure.com or via NuGet.com.
-
mercredi 4 avril 2012 08:54Modérateur
Hi Zendu,
Thank your for using Microsoft product.
As Lucifure mentioned, table storage supports single and double data type, if you want handle money type, try to use decimal type. you may need add following code in entity class:
[EntityDataType(PrimitiveTypeKind.String)]
About more details about error message, please try to post your idea on this site:
http://www.mygreatwindowsazureidea.com/forums/34192-windows-azure-feature-voting
Hope it can help you.
Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
- Marqué comme réponse Arwind - MSFTModerator lundi 9 avril 2012 07:37
- Non marqué comme réponse zendu lundi 28 mai 2012 13:53

