C# Azure表存储SDK-Can';t插入
我正在使用,可以很好地读取和删除实体,但插入操作会给我以下XmlException。有什么想法吗C# Azure表存储SDK-Can';t插入,c#,azure,C#,Azure,我正在使用,可以很好地读取和删除实体,但插入操作会给我以下XmlException。有什么想法吗 An exception of type 'System.Xml.XmlException' occurred in System.Xml.dll but was not handled in user code Additional information: Data at the root level is invalid. Line 1, position 1. 这是我的插入代码: Clou
An exception of type 'System.Xml.XmlException' occurred in System.Xml.dll but was not handled in user code
Additional information: Data at the root level is invalid. Line 1, position 1.
这是我的插入代码:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=myKey");
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("positions");
await table.CreateIfNotExistsAsync();
var p = new PositionEntity("test", Guid.NewGuid().ToString());
TableOperation insertOperation = TableOperation.Insert(p);
var result = table.ExecuteAsync(insertOperation).ContinueWith(t =>
{
if (t.Exception != null)
{
// read Exception here...
var x = RequestResult.TranslateFromExceptionMessage(t.Exception.Message);
}
});
注意:我在DNX 4.5.1上运行
编辑:
事实证明,myPositionEntity
具有未设置的DateTimeOffset属性。它不可为null,因此正在使用默认的DateTimeOffset值进行实例化。如果在发送之前手动设置Date属性,则插入可以正常工作
var p = new PositionEntity("test", Guid.NewGuid().ToString());
p.Date = DateTime.Now; // <-- This is required if default. Default value doesn't work!
有人知道为什么默认的DateTimeOffset值({01/01/0001 12:00:00 AM+00:00})在Azure表存储中不是有效值吗 支持的日期时间范围从公元1601年1月1日午夜12:00 UTC开始。该范围在9999年12月31日结束
仅供参考:已提供下表,详细说明Azure table Storage中数据类型的数据范围:您是否可以通过Fiddler或浏览器开发人员工具跟踪请求/响应,并查看通过网络发送的内容?这肯定有助于诊断这个问题。
<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>OutOfRangeInput</code><message xml:lang="en-US">One of the request inputs is out of range. RequestId:eeb6ed0c-0002-001f-48f5-f64ea4000000 Time:2015-09-24T18:18:32.8854764Z</message></error>