2015-10-27 99 views
0

我有一个在线Parse.com数据库,我可以创建对象并查询它们但不更新。在Parse.com文档的Xamarin部分,它只会告诉您如何在创建对象后直接更新对象,这是我不想做的。我尝试调整文档为其他平台所说的内容,但它没有奏效,我也尝试过查询数据库,然后直接输入新的字段值,但它将它们视为单独的函数。有没有人有任何帮助?如何使用Xamarin更新Parse.com数据库中的对象?

Parse.com文档:

// Create the object. 
var gameScore = new ParseObject("GameScore") 
{ 
    { "score", 1337 }, 
    { "playerName", "Sean Plott" }, 
    { "cheatMode", false }, 
    { "skills", new List<string> { "pwnage", "flying" } }, 
}; 
await gameScore.SaveAsync(); 

// Now let's update it with some new data. In this case, only cheatMode 
// and score will get sent to the cloud. playerName hasn't changed. 
gameScore["cheatMode"] = true; 
gameScore["score"] = 1338; 
await gameScore.SaveAsync(); 

我试过最近:

ParseQuery<ParseObject> query = ParseObject.GetQuery("cust_tbl"); 
IEnumerable<ParseObject> customers = await query.FindAsync(); 
customers["user"] = admin; 
record["score"] = 1338; 
await record; 
+0

请张贴代码显示你已经尝试过。 – Jason

回答

0

在你的榜样,你所得到的对象,而不是单个对象的列表(IEnumerable的)。相反,尝试这样的事情:

ParseQuery<ParseObject> query = ParseObject.GetQuery("cust_tbl"); 
// you need to keep track of the ObjectID assigned when you first saved, 
// otherwise you will have to query by some unique field like email or username 
ParseObject customer = await query.GetAsync(objectId); 

customer["user"] = admin; 
customer["score"] = 1338; 
await customer.SaveAsync(); 
+0

非常感谢!我的愚蠢的错误,这样的帮助。真的,谢谢你! – Monica

相关问题