示例#1
0
        /// <summary>
        /// Executes change interceptors and applies changes to the objects set for each entity contained in the change set
        /// </summary>
        protected virtual void ApplyChanges <TEntity>(TRepository repository, IEntitySet <TEntity> entitySet, IChangeSet changeSet, IList <TEntity> entityChangeSet, ClientInfo clientInfo) where TEntity : Entity
        {
            // apply changes to repository
            if (entityChangeSet != null && entityChangeSet.Count > 0)
            {
                foreach (var entity in entityChangeSet.ToArray())
                {
                    // run interceptors
                    ExecuteChangeInterceptors(repository, changeSet, entity, clientInfo);
                }
                foreach (var entity in entityChangeSet)
                {
                    // stop processing if transaction is not active
                    if (Transaction.Current.TransactionInformation.Status != TransactionStatus.Active)
                    {
                        return;
                    }

                    if (IsValid(entity))
                    {
                        // apply changes
                        entitySet.ApplyChanges(entity);
                    }
                }
            }
        }