/// <summary> /// Updates an existing <paramref name="record"/> in this repository. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="record">The <see cref="Record"/> which will be updated.</param> /// <param name="properties">The updated properties.</param> protected override Record DoUpdate(IMansionContext context, Record record, IPropertyBag properties) { // update the node repository.Update(context, record, properties); // merge the properties record.Merge(properties); // return the updated node return record; }
/// <summary> /// Updates an existing <paramref name="record"/> in this repository. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="record">The <see cref="Record"/> which will be updated.</param> /// <param name="properties">The updated properties.</param> protected override void DoUpdate(IMansionContext context, Record record, IPropertyBag properties) { // get the modified properties properties = PropertyBag.GetModifiedProperties(context, record, properties); if (properties.Count == 0) return; // build the query using (var connection = CreateConnection()) using (var transaction = connection.BeginTransaction()) using (var command = context.Nucleus.CreateInstance<UpdateCommand>()) { // init the command command.Prepare(context, connection, transaction, record, properties); // execute the command try { // execute the query command.Execute(); // woohoo it worked! transaction.Commit(); } catch (Exception) { // something terrible happened, revert everything transaction.Rollback(); throw; } } // merge the modified properties back into the node record.Merge(properties); }