2016-05-10 20 views
0

每當我嘗試訪問我的Azure的移動服務表,我得到以下錯誤:將值「AAAAAAAAB9c =」轉換爲鍵入「System.Version」時出錯。路徑「版本」

An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: Error converting value "AAAAAAAAB9k=" to type 'System.Version'. Path 'version', line 19, position 27.

這是發生這種錯誤的行:

await App.MobileService.GetTable<TodoItem>().InsertAsync(todoItem); 

我不實際上需要我的表中的版本值。此值由Azure自動生成。有沒有辦法強制忽略版本值?

這是的TodoItem定義:

public class TodoItem 
    { 
    public string Id { get; set; } 
    public DateTime createdAt { get; set; } 
    public DateTime updatedAt { get; set; } 
    public Version version { get; set; } 
    public bool deleted { get; set; } 

    ... and so on... 
} 
+1

「TodoItem」的定義是什麼? –

+0

您是否曾嘗試在'TodoItem'類的'Version'屬性中添加'[JsonIgnore]'? –

+0

我已編輯該問題以包含該定義。謝謝! – RockAndaHardPlace

回答

0

我會避免使用System.Version用於這一目的。 System.Version適用於數字版本值,例如遵循此模式的軟件版本:w.x.y.z。它看起來像你收到一個不適合的字符串,我也不希望你。

2

您的TodoItem代碼有誤。它應該是這樣的:

[Version] 
public string Version {get; set;} 

這裏[版本]引用VersionAttrbute是位於Microsoft.WindowsAzure.MobileServices命名空間。