2013-06-22 17 views
0

將數據從移動應用程序插入到蔚藍數據庫中時出現問題。無法將InsertAsync()插入到azure數據庫中

我在數據庫表的定義那樣:

enter image description here

此行病程一​​個錯誤:

 await usersTable.InsertAsync(
      new User 
      { 
       FirstName = this.FirstNameTextBox.Text, 
       LastName = this.LastNameTextBox.Text, 
       DepartmentID = 0, 
       LiveID = App.MobileService.CurrentUser.UserId, 
       Level = 0, 
       Pluses = 0, 
       Minuses = 0, 
      }); 

錯誤消息:

類型的例外,「系統。 ArgumentException'發生在mscorlib.dll中,但未在用戶代碼中處理 其他信息:如果i d成員已經設置。 如果有這種異常的處理程序,程序可能會安全地繼續。

這裏是一個User類的定義:

class User 
{ 
    [JsonProperty(PropertyName = "ID")] 
    public string LiveID { get; set; } 

    [JsonProperty(PropertyName = "FirstName")] 
    public string FirstName { get; set; } 

    [JsonProperty(PropertyName = "LastName")] 
    public string LastName { get; set; } 

    [JsonProperty(PropertyName = "DepartmentID")] 
    public int DepartmentID { get; set; } 

    [JsonProperty(PropertyName = "Level")] 
    public int Level { get; set; } 

    [JsonProperty(PropertyName = "Pluses")] 
    public int Pluses { get; set; } 

    [JsonProperty(PropertyName = "Minuses")] 
    public int Minuses { get; set; } 
} 
+0

我沒有意識到的是,ID列可以是任何東西,但int或BIGINT,但檢查出這個線程:HTTP://social.msdn.microsoft.com/Forums/windowsazure/en-US/18196872-6b47- 4bf6-bbe6-85f0e1e2e573/id-field-in-windows-azure-mobile-service也許將JsonProperty PropertyName屬性更改爲小寫「id」(並重新創建表)會有幫助嗎? –

回答

0

我遇到了類似的問題,在我的情況,調試過程中,我發現,我將用相同的唯一標識符,可以入口試試這個方向,並在插入前檢查重複。

相關問題