在将数据从移动应用程序插入天蓝色数据库时遇到问题。
我在数据库中的表是这样定义的:
此行会导致错误:
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,
});
错误信息:
mscorlib.dll 中出现“System.ArgumentException”类型的异常,但未在用户代码中处理附加信息:如果 id 成员已设置,则无法插入。如果有这个异常的处理程序,程序可以安全地继续。
这是用户类的定义:
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; }
}