src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignCommandSet.cs
/// <summary>
///     The method will do the following:
///     - Loop through the selected DSL property and get the model property from ModelXref and add it to the list.
///     - Call command to move properties and passed in the list that is created from previous step.
///     - Ensure that the properties that are moved are still selected after the move.
/// </summary>
The method will do the following:
Loop through the selected DSL property and get the model property from ModelXref and add it to the list.
Call command to move properties and passed in the list that is created from previous step.
Ensure that the properties that are moved are still selected after the move.
The method will do the following : Loop through the selected DSL property and get the model property from ModelXref and add it to the list . Call command to move properties and passed in the list that is created from previous step . Ensure that the properties that are moved are still selected after the move .
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
        private void DoSelectedPropertiesMove(MoveDirection moveDirection, uint moveStep)
        {
            Debug.Assert(
                SelectedProperty != null || SelectedNavigationProperty != null,
                "There must be at least 1 selected property or navigation property.");
            if (SelectedProperty != null
                || SelectedNavigationProperty != null)
            {
                var areNavigationPropertiesSelected = (SelectedProperty == null);
                var entityType = areNavigationPropertiesSelected ? SelectedNavigationProperty.EntityType : SelectedProperty.EntityType;
                Debug.Assert(entityType != null, "Unable to determine the entity-type of the selected properties.");
                if (entityType != null)
                {
                    var entityTypeShape = PresentationViewsSubject.GetPresentation(entityType).FirstOrDefault() as EntityTypeShape;
                    Debug.Assert(entityTypeShape != null, "Could not find the shape for entity-type: " + entityType.Name);
                    if (entityTypeShape != null)
                    {
                        var compartment = areNavigationPropertiesSelected
                                              ? entityTypeShape.NavigationCompartment
                                              : entityTypeShape.PropertiesCompartment;
                        var entityDesignerViewModel = entityType.EntityDesignerViewModel;
                        var modelProperties = new List<ModelEntity.PropertyBase>();
                        foreach (var property in CurrentSelection.OfType<PropertyBase>())
                        {
                            var modelProperty = entityDesignerViewModel.ModelXRef.GetExisting(property) as ModelEntity.PropertyBase;
                            Debug.Assert(
                                modelProperty != null, "Unable to get the model property for property : " + property.Name + "  from XRef.");
                            if (modelProperty != null)
                            {
                                modelProperties.Add(modelProperty);
                            }
                        }
                        if (modelProperties.Count > 0)
                        {
                            var uri = Utils.FileName2Uri(CurrentDocData.FileName);
                            var editingContext = PackageManager.Package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(uri);
                            var cpc = new CommandProcessorContext(
                                editingContext, EfiTransactionOriginator.EntityDesignerOriginatorId, Resources.Tx_MoveProperty);
                            CommandProcessor.InvokeSingleCommand(cpc, new MovePropertiesCommand(modelProperties, moveDirection, moveStep));
                            SelectProperties(modelProperties, compartment);
                        }
                    }
                }
            }
        }
[ SuppressMessage ( " " , " " ) ] private void DoSelectedPropertiesMove ( MoveDirection moveDirection , uint moveStep ) { Debug . Assert ( SelectedProperty != null || SelectedNavigationProperty != null , " " ) ; if ( SelectedProperty != null || SelectedNavigationProperty != null ) { var areNavigationPropertiesSelected = ( SelectedProperty == null ) ; var entityType = areNavigationPropertiesSelected ? SelectedNavigationProperty . EntityType : SelectedProperty . EntityType ; Debug . Assert ( entityType != null , " " ) ; if ( entityType != null ) { var entityTypeShape = PresentationViewsSubject . GetPresentation ( entityType ) . FirstOrDefault ( ) as EntityTypeShape ; Debug . Assert ( entityTypeShape != null , " " + entityType . Name ) ; if ( entityTypeShape != null ) { var compartment = areNavigationPropertiesSelected ? entityTypeShape . NavigationCompartment : entityTypeShape . PropertiesCompartment ; var entityDesignerViewModel = entityType . EntityDesignerViewModel ; var modelProperties = new List < ModelEntity . PropertyBase > ( ) ; foreach ( var property in CurrentSelection . OfType < PropertyBase > ( ) ) { var modelProperty = entityDesignerViewModel . ModelXRef . GetExisting ( property ) as ModelEntity . PropertyBase ; Debug . Assert ( modelProperty != null , " " + property . Name + " " ) ; if ( modelProperty != null ) { modelProperties . Add ( modelProperty ) ; } } if ( modelProperties . Count > 0 ) { var uri = Utils . FileName2Uri ( CurrentDocData . FileName ) ; var editingContext = PackageManager . Package . DocumentFrameMgr . EditingContextManager . GetNewOrExistingContext ( uri ) ; var cpc = new CommandProcessorContext ( editingContext , EfiTransactionOriginator . EntityDesignerOriginatorId , Resources . Tx_MoveProperty ) ; CommandProcessor . InvokeSingleCommand ( cpc , new MovePropertiesCommand ( modelProperties , moveDirection , moveStep ) ) ; SelectProperties ( modelProperties , compartment ) ; } } } } }
The method will do the following:
 Loop through the selected DSL property and get the model property from ModelXref and add it to the list.
The method will do the following : Loop through the selected DSL property and get the model property from ModelXref and add it to the list .
// Check whether navigation property or conceptual property are moved. // We don't support moving conceptual property and navigation property or moving properties that are belong to multiple entity type. // Restore the selections
moveDirection
MoveDirection
moveStep
uint