[英]Exception on Update azure mobile services data table
我正在嘗試使用azure移動服務開發Windows手機應用程序。 我正在使用azure portal提供的身份驗證服務。 身份驗證后,用戶需要輸入一些數據,如他的姓名,電子郵件ID等。另外,我限制一個用戶使用插入腳本只使用一行。 我正在使用多個頁面進行輸入。
為myTable
public class myTabble
{
public string Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string name { get; set; }
[JsonProperty(PropertyName = "age")]
public int age { get; set; }
[JsonProperty(PropertyName = "fname")]
public string fname { get; set; }
[JsonProperty(PropertyName = "street")]
public string street { get; set; }
[JsonProperty(PropertyName = "college")]
public string college { get; set; }
}
我的更新功能在第二頁按鈕上
private async void UpdateCheckedTodoItem(myTabble item)
{
await todoTable.UpdateAsync(item);
}
private async void myFunction()
{
var names = await todoTable
.Select(t => t.Id)
.ToEnumerableAsync();
var myName = names.FirstOrDefault();
string a = myName;
var item = await todoTable
.Where(todoItem => todoItem.Id == a)
.ToCollectionAsync();
item.street = street.Text; //error
item.colege = colege.Text; //error
}
private void save_Click(object sender, RoutedEventArgs e)
{
try
{
myFunction();
}
catch
{
MessageBox.Show("Invalid input");
}
}
我收到了這個錯誤
Microsoft.WindowsAzure.MobileServices.MobileServiceCollection<Test.myTabble,Test.myTabble>' does not contain a definition for 'hobby' and no extension method 'hobby' accepting a first argument of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceCollection<Test.myTabble,Test.myTabble>' could be found (are you missing a using directive or an assembly reference?
var items = await todoTable
.Where(todoItem => todoItem.Id == a)
.ToCollectionAsync();
var item = items.FirstOrDefault();
if(item != null)
{
item.street = street.Text; //
item.colege = colege.Text; //
await todoTable.UpdateAsync(item);
}
我幾乎忘記了API,我不記得是否有任何調用得到一個,在這種情況下你不必執行ToCollectionAsync()
,它返回一個collection
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.