由于某种原因,这个程序没有从 parse.com 返回实时数据,它只是在我退出应用程序时返回正确的数据,我需要从解析中检索数据,例如,如果有人更改了解析中的数据,则其反映在该应用程序
public async Task<List<MagicLists>> GetListsAync()
{
var query = ParseObject.GetQuery("lists");
IEnumerable<ParseObject> result = new List<ParseObject>();
try
{
result = await query.FindAsync();
}
catch (Exception) { }
var listItems = new List<MagicLists>();
foreach (var listItemParseObject in result)
{
var listItem = await MagicLists.CreateFromParseObject(listItemParseObject);
listItems.Add(listItem);
}
return listItems;
}
我的清单如下,我不明白为什么它不只是得到
using Parse;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
namespace MagicLists.DataModel
{
public class MagicLists : INotifyPropertyChanged
{
public MagicLists() { }
public MagicLists(String uniqueId, String title, String subtitle, String imagePath, String description, String content, string type)
{
this.UniqueId = uniqueId;
this.Title = title;
this.Subtitle = subtitle;
this.Description = description;
this.ImagePath = imagePath;
this.Content = content;
this.Type = type;
}
public MagicLists(String uniqueId, String title, String subtitle, String imagePath, String description, String content, bool unread, Int32 status)
{
UniqueId = uniqueId;
Title = title;
Subtitle = subtitle;
Description = description;
ImagePath = imagePath;
Content = content;
Unread = unread;
Status = status;
}
private bool _unread;
private string _title;
public string UniqueId { get; private set; }
public string Title
{
get { return _title; }
set
{
_title = value;
NotifyPropertyChanged("Title");
}
}
public string Subtitle { get; private set; }
public string Description { get; private set; }
public string ImagePath { get; private set; }
public string Content { get; private set; }
public int Status { get; private set; }
public string Type { get; private set; }
public string ViewToUse { get; private set; }
public bool Unread
{
get { return _unread; }
set
{
_unread = value;
NotifyPropertyChanged("Unread");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public static async Task<MagicLists> CreateFromParseObject(ParseObject parseObject)
{
return await Task.Run<MagicLists>(() =>
{
var mlist = new MagicLists();
mlist.Title = parseObject.ObjectId;
if (parseObject.ContainsKey("name"))
{
mlist.Title = (string)parseObject["name"];
}
if (parseObject.ContainsKey("description"))
{
mlist.Description = (string)parseObject["description"];
}
if (parseObject.ContainsKey("image"))
{
mlist.ImagePath = (string)parseObject["image"];
}
if (parseObject.ContainsKey("type"))
{
string mtype = (string)parseObject["type"];
if (mtype == "N")
{
mlist.Type = "Notes";
mlist.ViewToUse = "Notes.Xaml";
}
}
return mlist;
});
}
}
}
在我的列表视图刷新中,我正在执行以下操作
private async Task LstView_OnPullToRefreshRequested(object sender, EventArgs e)
{
lstView.ItemsSource = null;
List<DataModel.MagicLists> mLists;
mLists = await _db.GetListsAync();
lstView.ItemsSource = mLists;
}
但是它只是带回旧数据而不是解析中调整后的数据?.
以防万一其他人发现这确实是 Windows Phone 8.1 的解析 sdk 中的一个错误,并且已在下一个版本中修复,正如他们在我原来的错误跟踪器中所说的那样。