public virtual IEnumerable <PersistAction> GetPersistSequence(EntityChangeRegistry registry) { // Delete foreach (var action in GetDeleteSequence(GetRemovedStates(registry))) { yield return(action); } // Update foreach (var state in registry.GetItems(PersistenceState.Modified)) { if (state.IsNotAvailableOrMarkedAsRemoved) { continue; } yield return(new PersistAction(Node, state, PersistActionKind.Update)); state.DifferentialTuple.Merge(); } // Insert foreach (var action in GetInsertSequence(GetCreatedStates(registry))) { yield return(action); } // Commit state differences, if any foreach (var state in GetCreatedStates(registry)) { state.CommitDifference(); } }
public RemapContext(EntityChangeRegistry registry) { ArgumentValidator.EnsureArgumentNotNull(registry, "registry"); this.registry = registry; keyMap = new Dictionary <Key, Key>(); readOnlyKeyMap = new ReadOnlyDictionary <Key, Key>(keyMap, false); }
/// <summary> /// Remap temporary (local) keys to real (will be saved to storage) keys. /// </summary> /// <param name="registry">Registry that contains changed <see cref="EntityState">states of entity.</see></param> /// <returns>Mapping temporary keys to real keys.</returns> public KeyMapping Remap(EntityChangeRegistry registry) { var context = new RemapContext(registry); RemapEntityKeys(context); RemapReferencesToEntities(context); Session.ReferenceFieldsChangesRegistry.Clear(); return(context.KeyMapping); }
public void Process(EntityChangeRegistry registry) { activeRegistry = registry; PinAll(); PinnedItems = new EntityChangeRegistry(Session); PersistableItems = new EntityChangeRegistry(Session); ProcessRegistry(PersistenceState.New); ProcessRegistry(PersistenceState.Modified); ProcessRegistry(PersistenceState.Removed); ClearPinned(); activeRegistry = null; }
public void Reset() { PinnedItems = null; PersistableItems = null; }
protected static IEnumerable <EntityState> GetRemovedStates(EntityChangeRegistry registry) { return(registry .GetItems(PersistenceState.Removed) .Except(registry.GetItems(PersistenceState.New))); }
protected static IEnumerable <EntityState> GetCreatedStates(EntityChangeRegistry registry) { return(registry .GetItems(PersistenceState.New) .Where(state => !state.IsNotAvailableOrMarkedAsRemoved)); }