2012-06-29 52 views
0

當我嘗試從表存儲讀取時,出現以下異常。我在添加DateTime?屬性後得到它。Azure Table Storage:字符串''不是有效的AllXsd值

例外:

The current value 'String.Empty' type is not compatible with the expected 'System.DateTime' type. 

內部異常:

The string '' is not a valid AllXsd value. 

我想通過以下方法解決:

  1. 我得到的供應商來映射不存在值爲空
  2. 更新帶有日期的對象(但我不能把它拿來?)

有沒有人對如何解決這一問題更好的主意嗎?

堆棧跟蹤:

System.InvalidOperationException: The current value 'String.Empty' type is not compatible with the expected 'System.DateTime' type. ---> System.FormatException: The string '' is not a valid AllXsd value. 
    at System.Xml.Schema.XsdDateTime..ctor(String text, XsdDateTimeFlags kinds) 
    at System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption) 
    at System.Data.Services.Client.ClientConvert.ChangeType(String propertyValue, Type propertyType) 
    --- End of inner exception stack trace --- 
    at System.Data.Services.Client.ClientConvert.ChangeType(String propertyValue, Type propertyType) 
    at System.Data.Services.Client.AtomMaterializer.MaterializeDataValue(Type type, AtomContentProperty atomProperty, DataServiceContext context) 
    at System.Data.Services.Client.AtomMaterializer.MaterializeDataValues(ClientType actualType, List`1 values, Boolean ignoreMissingProperties, DataServiceContext context) 
    at System.Data.Services.Client.AtomMaterializer.MaterializeResolvedEntry(AtomEntry entry, Boolean includeLinks) 
    at System.Data.Services.Client.AtomMaterializer.Materialize(AtomEntry entry, Type expectedEntryType, Boolean includeLinks) 
    at System.Data.Services.Client.AtomMaterializer.DirectMaterializePlan(AtomMaterializer materializer, AtomEntry entry, Type expectedEntryType) 
    at System.Data.Services.Client.AtomMaterializerInvoker.DirectMaterializePlan(Object materializer, Object entry, Type expectedEntryType) 
    at System.Data.Services.Client.ProjectionPlan.Run(AtomMaterializer materializer, AtomEntry entry, Type expectedType) 
    at System.Data.Services.Client.AtomMaterializer.Read() 
    at System.Data.Services.Client.MaterializeAtom.MoveNextInternal() 
    at System.Data.Services.Client.MaterializeAtom.MoveNext() 
    at System.Linq.Enumerable.<CastIterator>d__b1`1.MoveNext() 
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) 
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) 

型號

class Car : TableServiceEntity { 

public DateTime? LastUpdated { get; set; } 
public DateTime? LastUsed { get; set; } 

// more properties 

} 

查詢

var sx = this.GetServiceContext(); 
return (from x in sx.CreateQuery<Car>("Table") select x).ToList(); 

回答

0

我找到了解決辦法,如果有人網上搜尋它:

我使用的是Azure存儲資源管理器,當我在測試時更新另一個屬性時,它在其中一個實體中保存了一個空字符串而不是空的日期。

相關問題