src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignCommandSet.cs
/// <summary>
///     Given the list of model Property, select the corresponding DSL Properties' shapes in the diagram.
///     The list contains:
///     - Properties that are belong to a single entity.
///     - Either conceptual properties or navigation properties. It cannot contain both.
/// </summary>
/// <param name="modelProperties"></param>
/// <param name="compartment"></param>
Given the list of model Property, select the corresponding DSL Properties' shapes in the diagram.
The list contains:
Properties that are belong to a single entity.
Either conceptual properties or navigation properties. It cannot contain both.
Given the list of model Property select the corresponding DSL Properties ' shapes in the diagram . The list contains : Properties that are belong to a single entity . Either conceptual properties or navigation properties . It cannot contain both .
private void SelectProperties(List<ModelEntity.PropertyBase> modelProperties, ElementListCompartment compartment)
        {
            if (modelProperties.Count > 0)
            {
                var arePropertiesBelongToASingleEntityType = (modelProperties.Select(p => p.EntityType).Distinct().Count() == 1);
                Debug.Assert(arePropertiesBelongToASingleEntityType, "The properties are not belong to a single entity-type");
                if (arePropertiesBelongToASingleEntityType)
                {
                    var diagram = GetDiagram();
                    Debug.Assert(diagram != null, "Unable to get DSL diagram instance.");
                    if (diagram != null)
                    {
                        var entityDesignerViewModel = diagram.ModelElement;
                        var selections = new DiagramItemCollection();
                        foreach (var property in modelProperties)
                        {
                            var vmProperty = entityDesignerViewModel.ModelXRef.GetExisting(property) as PropertyBase;
                            Debug.Assert(vmProperty != null, "Unable to find DSL model property for property:" + property.DisplayName);
                            if (vmProperty != null)
                            {
                                var index = compartment.Items.IndexOf(vmProperty);
                                Debug.Assert(
                                    index >= 0, "Unable find the index of DSL property :" + vmProperty.Name + " in compartment list.");
                                if (index >= 0)
                                {
                                    selections.Add(new DiagramItem(compartment, compartment.ListField, new ListItemSubField(index)));
                                }
                            }
                        }
                        if (diagram != null
                            && diagram.ActiveDiagramView != null
                            && selections.Count > 0)
                        {
                            diagram.ActiveDiagramView.Selection.Set(selections);
                        }
                    }
                }
            }
        }
private void SelectProperties ( List < ModelEntity . PropertyBase > modelProperties , ElementListCompartment compartment ) { if ( modelProperties . Count > 0 ) { var arePropertiesBelongToASingleEntityType = ( modelProperties . Select ( p => p . EntityType ) . Distinct ( ) . Count ( ) == 1 ) ; Debug . Assert ( arePropertiesBelongToASingleEntityType , " " ) ; if ( arePropertiesBelongToASingleEntityType ) { var diagram = GetDiagram ( ) ; Debug . Assert ( diagram != null , " " ) ; if ( diagram != null ) { var entityDesignerViewModel = diagram . ModelElement ; var selections = new DiagramItemCollection ( ) ; foreach ( var property in modelProperties ) { var vmProperty = entityDesignerViewModel . ModelXRef . GetExisting ( property ) as PropertyBase ; Debug . Assert ( vmProperty != null , " " + property . DisplayName ) ; if ( vmProperty != null ) { var index = compartment . Items . IndexOf ( vmProperty ) ; Debug . Assert ( index >= 0 , " " + vmProperty . Name + " " ) ; if ( index >= 0 ) { selections . Add ( new DiagramItem ( compartment , compartment . ListField , new ListItemSubField ( index ) ) ) ; } } } if ( diagram != null && diagram . ActiveDiagramView != null && selections . Count > 0 ) { diagram . ActiveDiagramView . Selection . Set ( selections ) ; } } } } }
Given the list of model Property, select the corresponding DSL Properties' shapes in the diagram.
Given the list of model Property select the corresponding DSL Properties ' shapes in the diagram .
// Check to see all the properties belong to a single entityType. // Loop through model property, find the DSL property from model xref. // Given the DSL property find the index of the property in the ElementListCompartment.
modelProperties
List<ModelEntity.PropertyBase>
None
compartment
ElementListCompartment
None