2015-10-27 83 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

相關問題