src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignCommandSet.cs
/// <summary>
///     Method that will handle delete request in designer.
///     This method will fire DSL rules that deletes Escher model element.
///     It will also determine whether StorageEntitySets would be unmapped if the delete went ahead and provide the user a choice to proceed or not.
/// </summary>
Method that will handle delete request in designer.
This method will fire DSL rules that deletes Escher model element.
It will also determine whether StorageEntitySets would be unmapped if the delete went ahead and provide the user a choice to proceed or not.
Method that will handle delete request in designer . This method will fire DSL rules that deletes Escher model element . It will also determine whether StorageEntitySets would be unmapped if the delete went ahead and provide the user a choice to proceed or not .
internal void ProcessDesignerOnMenuDelete()
        {
            var diagram = GetDiagram();
            Debug.Assert(diagram != null, "diagram should not be null");
            if (diagram != null
                && OnlyDeletableObjectsSelected()) 
            {
                var selectedModelElements = new List<EFElement>();
                foreach (var ets in SelectedEntityTypeShapes)
                {
                    var viewModelEntityType = ets.TypedModelElement;
                    var cet =
                        viewModelEntityType.EntityDesignerViewModel.ModelXRef.GetExisting(viewModelEntityType) as
                        ModelEntity.ConceptualEntityType;
                    if (null != cet)
                    {
                        selectedModelElements.Add(cet);
                    }
                }
                foreach (var assocConnector in SelectedAssociationConnectors)
                {
                    var viewModelAssociation = assocConnector.ModelElement;
                    var assoc =
                        viewModelAssociation.SourceEntityType.EntityDesignerViewModel.ModelXRef.GetExisting(viewModelAssociation) as
                        ModelEntity.Association;
                    if (null != assoc)
                    {
                        selectedModelElements.Add(assoc);
                    }
                }
                var result = diagram.ShouldDeleteUnmappedStorageEntitySets(selectedModelElements);
                if (DialogResult.Cancel == result)
                {
                    return;
                }
                ProcessOnMenuDeleteCommand();
            }
        }
internal void ProcessDesignerOnMenuDelete ( ) { var diagram = GetDiagram ( ) ; Debug . Assert ( diagram != null , " " ) ; if ( diagram != null && OnlyDeletableObjectsSelected ( ) ) { var selectedModelElements = new List < EFElement > ( ) ; foreach ( var ets in SelectedEntityTypeShapes ) { var viewModelEntityType = ets . TypedModelElement ; var cet = viewModelEntityType . EntityDesignerViewModel . ModelXRef . GetExisting ( viewModelEntityType ) as ModelEntity . ConceptualEntityType ; if ( null != cet ) { selectedModelElements . Add ( cet ) ; } } foreach ( var assocConnector in SelectedAssociationConnectors ) { var viewModelAssociation = assocConnector . ModelElement ; var assoc = viewModelAssociation . SourceEntityType . EntityDesignerViewModel . ModelXRef . GetExisting ( viewModelAssociation ) as ModelEntity . Association ; if ( null != assoc ) { selectedModelElements . Add ( assoc ) ; } } var result = diagram . ShouldDeleteUnmappedStorageEntitySets ( selectedModelElements ) ; if ( DialogResult . Cancel == result ) { return ; } ProcessOnMenuDeleteCommand ( ) ; } }
Method that will handle delete request in designer.
Method that will handle delete request in designer .
// should not process this command when nothing or only the diagram itself are selected // determine what StorageEntitySets would be unmapped if this delete // went ahead. If there are any then offer the user the choice of // whether to delete them also. // offer the user their choice of whether to delete the storage EntitySets // (this has the side-effect of adding a list of unmapped ones to the  // DeleteUnmappedStorageEntitySetsProperty) // user decided to cancel the whole operation // do the delete