public static async Task <List <ParseObject> > SaveAll(List <ParseObject> objectList) { if (objectList == null) { throw new ArgumentNullException(nameof(objectList)); } foreach (ParseObject obj in objectList) { if (ParseBatch.HasCircleReference(obj, new HashSet <ParseObject>())) { throw new ArgumentException("Found a circle dependency when save."); } } Stack <ParseBatch> batches = ParseBatch.BatchObjects(objectList, true); await SaveBatches(batches); return(objectList); }
public async Task <ParseObject> Save(bool fetchWhenSave = false, ParseQuery <ParseObject> query = null) { if (ParseBatch.HasCircleReference(this, new HashSet <ParseObject>())) { throw new ArgumentException("Found a circle dependency when save."); } Stack <ParseBatch> batches = ParseBatch.BatchObjects(new List <ParseObject> { this }, false); if (batches.Count > 0) { await SaveBatches(batches); } string path = ObjectId == null ? $"classes/{ClassName}" : $"classes/{ClassName}/{ObjectId}"; Dictionary <string, object> queryParams = new Dictionary <string, object>(); if (fetchWhenSave) { queryParams["fetchWhenSave"] = true; } if (query != null) { queryParams["where"] = query.BuildWhere(); } Dictionary <string, object> response = ObjectId == null ? await ParseClient.HttpClient.Post <Dictionary <string, object> >(path, data : ParseEncoder.Encode(operationDict) as Dictionary <string, object>, queryParams : queryParams) : await ParseClient.HttpClient.Put <Dictionary <string, object> >(path, data : ParseEncoder.Encode(operationDict) as Dictionary <string, object>, queryParams : queryParams); ParseObjectData data = ParseObjectData.Decode(response); Merge(data); return(this); }