/// <summary> /// Saves the changes made by the client. /// </summary> /// <param name="saveBundle">The changes to save.</param> /// <param name="saveChangesOptions">The saving options.</param> /// <returns>The save result.</returns> protected SaveResult SaveChanges(SaveBundle saveBundle, SaveChangesOptions saveChangesOptions) { var saveWorkState = _saveWorkStateFactory.Create(saveBundle, info => AfterCreateEntityInfo(info, saveBundle.SaveOptions) && (saveChangesOptions.AfterCreateEntityInfoAction?.Invoke(info, saveBundle.SaveOptions) ?? true)); try { var context = new SaveChangesContext(saveWorkState.SaveMap, saveBundle.SaveOptions); return(SaveChangesCore(saveWorkState, context, saveChangesOptions)); } catch (Exception e) { if (!HandleSaveException(e, saveWorkState)) { throw; } } return(saveWorkState.ToSaveResult()); }
/// <summary> /// Saves the changes made by the client. /// </summary> /// <param name="workState">The save work state.</param> /// <param name="context">The save context.</param> /// <param name="saveChangesOptions">The save options.</param> /// <returns>The save result.</returns> protected virtual SaveResult SaveChangesCore(SaveWorkState workState, SaveChangesContext context, SaveChangesOptions saveChangesOptions) { workState.KeyMappings = _entityUpdater.FetchAndApplyChanges(this, context, saveChangesOptions); return(workState.ToSaveResult()); }