0

我正在使用 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;
    }
}

我对此有一些歧义错误。我知道我使用的是相同的名称,但这些是我的列名。我怎样才能使这项工作能够读取另一页上保存的数据?

4

1 回答 1

-1

修复了问题!改了几个名字

于 2013-04-25T07:54:46.430 回答