/// <summary> /// Deletes the edge /// </summary> /// <param name="document">document reference</param> /// <param name="waitForSync">Wait until document has been synced to disk</param> /// <returns></returns> public async Task <bool> RemoveAsync(object document, bool?waitForSync = null, string ifMatchRev = null, Action <BaseResult> baseResult = null) { if (db.Setting.DisableChangeTracking == true) { throw new InvalidOperationException("Change tracking is disabled, use RemoveById() instead"); } var container = db.ChangeTracker.FindDocumentInfo(document); BaseResult bResult = null; var result = await RemoveByIdAsync(container.Id, waitForSync, ifMatchRev, (b) => bResult = b).ConfigureAwait(false); if (baseResult != null) { baseResult(bResult); } if (bResult.HasError() == false) { db.ChangeTracker.StopTrackChanges(document); } return(result); }
/// <summary> /// Completely updates the edge /// </summary> /// <param name="document">Representation of the new document</param> /// <param name="waitForSync">Wait until document has been synced to disk</param> /// <returns>Document identifiers</returns> public async Task <IDocumentIdentifierResult> ReplaceAsync(object document, bool?waitForSync = null, string ifMatchRev = null, Action <BaseResult> baseResult = null) { if (db.Setting.DisableChangeTracking == true) { throw new InvalidOperationException("Change tracking is disabled, use ReplaceById() instead"); } var container = db.ChangeTracker.FindDocumentInfo(document); BaseResult bResult = null; var result = await ReplaceByIdAsync(container.Id, document, waitForSync, ifMatchRev, (b) => bResult = b).ConfigureAwait(false); if (baseResult != null) { baseResult(bResult); } if (bResult.HasError() == false) { container.Rev = result.Rev; container.Document = JObject.FromObject(document, new DocumentSerializer(db).CreateJsonSerializer()); db.SharedSetting.IdentifierModifier.FindIdentifierMethodFor(document.GetType()).SetRevision(document, result.Rev); } return(result); }
public void Throw(BaseResult baseResult) { if (baseResult.HasError()) { throw new ArangoServerException(baseResult); } }
///<summary> ///Partially updates the edge ///</summary> ///<param name="document">Representation of the patch document</param> ///<param name="keepNull">For remove any attributes from the existing document that are contained in the patch document with an attribute value of null</param> ///<param name="waitForSync">Wait until document has been synced to disk</param> ///<returns>Document identifiers</returns> public async Task <IDocumentIdentifierResult> UpdateAsync(object document, bool?waitForSync = null, bool?keepNull = null, string ifMatchRev = null, Action <BaseResult> baseResult = null) { if (db.Setting.DisableChangeTracking == true) { throw new InvalidOperationException("Change tracking is disabled, use UpdateById() instead"); } DocumentContainer container = null; JObject jObject = null; var changed = db.ChangeTracker.GetChanges(document, out container, out jObject); if (changed.Count != 0) { BaseResult bResult = null; var result = await UpdateByIdAsync(container.Id, changed, waitForSync, keepNull, ifMatchRev, (b) => bResult = b).ConfigureAwait(false); if (bResult.HasError() == false) { container.Rev = result.Rev; container.Document = jObject; db.SharedSetting.IdentifierModifier.FindIdentifierMethodFor(document.GetType()).SetRevision(document, result.Rev); } return(result); } else { return new DocumentIdentifierWithoutBaseResult() { Id = container.Id, Key = container.Key, Rev = container.Rev } }; }
public void ThrowIfNeeded(BaseResult baseResult) { if (baseResult.HasError() && db.Setting.ThrowForServerErrors == true) { throw new ArangoServerException(baseResult); } }