I'm creating a Windows 8 Store App (c#) using Windows Azure Mobile Services to store my data. I can successfully add data to the Table (ToDoItem) but got problems with reading it.
To add Data:
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);
}
}
So this piece of code works! Now the problem: I want to read the data from the Mobile Service in another blank page:
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;
}
}
I have some Ambiguity errors with this. I know I'm using the same names but those are my column names. How can I make this work so it would be able to read the saved data on another page??
Fixed the problem! Changed a few names
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.