void ApplyOperation( UnitOfWorkAction action, IList <IDomainObject> affectedEntities, SuccessfulUoWInvocationDelegate successfulInvocation, FailedUoWInvocationDelegate failedInvocation ) { for (int index = 0; index < affectedEntities.Count; index++) { IDomainObject entity = affectedEntities[index]; if (entity == null) { continue; } IBaseMapper mapper = entity.Mapper; OperationDelegate operation = GetOperation(action, mapper); bool success = operation(ref entity, (domainObject, results) => { if (successfulInvocation != null) { successfulInvocation(domainObject, action, results); } }, (domainObject, results) => { if (failedInvocation != null) { failedInvocation(domainObject, action, results); } }); } }
public void Commit(SuccessfulUoWInvocationDelegate successfulInvocation, FailedUoWInvocationDelegate failedInvocation) { ApplyOperation(UnitOfWorkAction.Insert, _insertionObjects.Values.ToList(), successfulInvocation, failedInvocation); ApplyOperation(UnitOfWorkAction.Update, _updatingObjects.Values.ToList(), successfulInvocation, failedInvocation); ApplyOperation(UnitOfWorkAction.Delete, _deletionObjects.Values.ToList(), successfulInvocation, failedInvocation); ClearUnitOfWork(); }