src/Misc/EFTools/EntityDesignModel/Commands/DeleteComplexTypeCommand.cs
/// <summary>
///     We override this method because we need to do some extra things before
///     the normal PreInvoke gets called and our antiDeps are removed
/// </summary>
/// <param name="cpc"></param>
We override this method because we need to do some extra things before
the normal PreInvoke gets called and our antiDeps are removed
We override this method because we need to do some extra things before the normal PreInvoke gets called and our antiDeps are removed
protected override void PreInvoke(CommandProcessorContext cpc)
        {
            foreach (var property in EFElement.GetAntiDependenciesOfType<ComplexConceptualProperty>())
            {
                foreach (var cp in property.GetAntiDependenciesOfType<ComplexProperty>())
                {
                    DeleteInTransaction(cpc, cp);
                }
                if (property.ComplexType.Target != null)
                {
                    property.ComplexType.SetRefName(null);
                    property.ComplexType.SetRefName(property.ComplexType.Target);
                    property.ComplexType.Rebind();
                }
                property.ComplexType.Unbind();
                _complexPropertiesToResolve.Add(property);
            }
            base.PreInvoke(cpc);
        }
protected override void PreInvoke ( CommandProcessorContext cpc ) { foreach ( var property in EFElement . GetAntiDependenciesOfType < ComplexConceptualProperty > ( ) ) { foreach ( var cp in property . GetAntiDependenciesOfType < ComplexProperty > ( ) ) { DeleteInTransaction ( cpc , cp ) ; } if ( property . ComplexType . Target != null ) { property . ComplexType . SetRefName ( null ) ; property . ComplexType . SetRefName ( property . ComplexType . Target ) ; property . ComplexType . Rebind ( ) ; } property . ComplexType . Unbind ( ) ; _complexPropertiesToResolve . Add ( property ) ; } base . PreInvoke ( cpc ) ; }
We override this method because we need to do some extra things before
the normal PreInvoke gets called and our antiDeps are removed
We override this method because we need to do some extra things before the normal PreInvoke gets called and our antiDeps are removed
// remove the type of all related complex properties (so they won't get deleted) // also delete all related ComplexProperty mappings // rebind property.ComplexType to what it is bound to now. This adds a change to that SingleItemBinding // to the list of actions that this command takes (but note that its RefValue does not change). // This is important so that if Undo is called on this command that SingleItemBinding will be rebound back // to the re-added ComplexType. It is likely that this command will also delete ComplexProperty mappings (see just above). // If an Undo happens the resolve step for the ScalarProperty children of those mappings will fail if at // that time the property.ComplexType SingleItemBinding is not resolved. // have to set to null and then reset because just setting to the existing value is shortcircuited out // unbind the property.ComplexType but leave the reference pointing to the soon to be non-existent ComplexType // so that the error message tells the user what has happened (and what they can do to fix it)
cpc
CommandProcessorContext
None