C# 如何在UWP C中读取、复制和显示azure移动表中的项目#
使用Azure移动服务,我可以使用以下代码将项目添加到Azure表:C# 如何在UWP C中读取、复制和显示azure移动表中的项目#,c#,azure,mobile,uwp,C#,Azure,Mobile,Uwp,使用Azure移动服务,我可以使用以下代码将项目添加到Azure表: private async void Aggi_Click(object sender, RoutedEventArgs e) { Bestemmye oggetto = new Bestemmye { Text = RicBest.Text //a textbox }; await App.MobileService
private async void Aggi_Click(object sender, RoutedEventArgs e)
{
Bestemmye oggetto = new Bestemmye
{
Text = RicBest.Text //a textbox
};
await App.MobileService.GetTable<Bestemmye>().InsertAsync(oggetto);
}
private async void Aggi\u Click(对象发送方、路由目标方)
{
Bestemmye oggetto=新的Bestemmye
{
Text=RicBest.Text//文本框
};
等待App.MobileService.GetTable().InsertAsync(oggetto);
}
如何读取表格项目?如何将它们保存到列表框中?因此我知道这与您现在使用的完全不同。但是我也有很多问题让所有的东西都能正常工作。这就是我现在用的 插入数据
IMobileServiceTable<Test> TestObj = App.MobileService.GetTable<Test>();
try
{
Test obj = new Test();
obj.test = test.Text;
obj.test1 = test1.Text;
obj.test2 = test2.Text;
obj.test3 = test3.Text;
TestObj.InsertAsync(obj);
MessageDialog msgDialog = new MessageDialog("Data Inserted!!!");
msgDialog.ShowAsync();
}
catch (Exception ex)
{
MessageDialog msgDialogError = new MessageDialog("Error : " + ex.ToString()); msgDialogError.ShowAsync();
}
执行该代码以读取:
private async void button1_Click(object sender, RoutedEventArgs e)
{
IMobileServiceTable<Test> productTest = App.MobileService.GetTable<Test>();
// This query filters out.
MobileServiceCollection<Test, Test> products = await productTest
.Where(Test => Test.test == "Test")
.ToCollectionAsync();
lb.ItemsSource = products;
}
private async void按钮1\u单击(对象发送方,路由目标)
{
IMobileServiceTable productTest=App.MobileService.GetTable();
//这个查询过滤掉了。
MobileServiceCollection产品=等待产品测试
.Where(Test=>Test.Test==“Test”)
.ToCollectionAsync();
lb.ItemsSource=产品;
}
现在是XAML列表框
<ListBox
x:Name="lb">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="152">
<TextBlock Text="{Binding test}"></TextBlock>
<TextBlock Text="{Binding test1}"></TextBlock>
<TextBlock Text="{Binding test2}"></TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我花了50个小时才发现这一点,但它对我有效。@CSharpRocks我什么都没试过,这是我第一次使用azure。。。我在azure中的快速启动选项中找到了这一点,它很有效。但在阅读表项时,我没有发现类似的代码
<ListBox
x:Name="lb">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="152">
<TextBlock Text="{Binding test}"></TextBlock>
<TextBlock Text="{Binding test1}"></TextBlock>
<TextBlock Text="{Binding test2}"></TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>