它是 Windows Phone 8 (Azure) 应用程序。我尝试将整个表 PicturesTable 获取到 PictureList。但我只有空行(行数与 Azure 数据库中的行数相同,因此它同步正确但没有值)。
public class PicturesTableItem
{
public int Id { get; set; }
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "category")]
public string Category { get; set; }
[DataMember(Name = "address")]
public string Address { get; set; }
}
public partial class MainPage : PhoneApplicationPage
{
private MobileServiceCollectionView<PicturesTableItem> PicturesItems;
private IMobileServiceTable<PicturesTableItem> PicturesTable = App.MobileService.GetTable<PicturesTableItem>();
private List<PicturesTableItem> PictureList = new List<PicturesTableItem>();
// Constructor
public MainPage()
{
InitializeComponent();
// Set the data context of the listbox control to the sample data
DataContext = App.ViewModel;
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
private void RefreshPicturesTableItems()
{
PicturesItems = PicturesTable.ToCollectionView();
}
/*
* Override
*/
protected override void OnNavigatedTo(NavigationEventArgs e)
{
RefreshPicturesTableItems();
}
}
我想以这种方式展示它
string temp = "";
foreach (var element in PictureList)
{
temp = temp + element.Address.ToString()+"\n";
}
MessageBox.Show(temp.ToString());
你能告诉我如何以好的方式做到这一点吗?
我不能去
PictureList = PicturesTable.ToListAsync();