我正在使用Windows Azure移动服务创建一个Windows 8商店应用程序(c#)来存储我的数据。 我可以成功地将数据添加到表(ToDoItem),但是在阅读时遇到了问题。
添加数据:
public class TodoItem
{
public int Id { get; set; }
[DataMember(Name = "text")]
public string Text { get; set; }
[DataMember(Name = "Private")]
public bool Private { get; set; }
[DataMember(Name = "FirstTeam")]
public string Team1 { get; set; }
[DataMember(Name = "SecondTeam")]
public string Team2 { get; set; }
}
public sealed partial class ViewItems : Page
{
private ObservableCollection<TodoItem> items;
private IMobileServiceTable<TodoItem> todoTable = App.MobileService.GetTable<TodoItem>();
private async void InsertTodoItem(TodoItem todoItem)
{
await todoTable.InsertAsync(todoItem);
}
private void ButtonSave_Click(object sender, RoutedEventArgs e)
{
var todoItem = new TodoItem { Text = Ploeg1.Text, Team1 = Ploeg1.Text, Team2 = Ploeg2.Text};
InsertTodoItem(todoItem);
}
}
所以这段代码可行!现在问题是:我想在另一个空白页面中阅读移动服务中的数据:
public class TodoItem
{
public int Id { get; set; }
[DataMember(Name = "text")]
public string Text { get; set; }
[DataMember(Name = "Private")]
public bool Private { get; set; }
[DataMember(Name = "FirstTeam")]
public string Team1 { get; set; }
[DataMember(Name = "SecondTeam")]
public string Team2 { get; set; }
}
public sealed partial class gamestore : Page
{
private ObservableCollection<TodoItem> items;
private IMobileServiceTable<TodoItem> todoTable = App.MobileService.GetTable<TodoItem>();
private void ButtonRefresh_Click(object sender, RoutedEventArgs e)
{
RefreshTodoItems();
}
private async void RefreshTodoItems()
{
var results = await todoTable2
.Where(todoItem => todoItem.Private == false)
.ToListAsync();
items = new ObservableCollection<TodoItem>(results);
ListItems.ItemsSource = items;
}
}
我有一些歧义错误。我知道我使用相同的名称,但这些是我的列名。如何使这项工作能够在另一页上读取保存的数据?
答案 0 :(得分:-1)
修正了问题!改了几个名字