protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // first create new ComplexType
            _createdComplexType = CreateComplexTypeCommand.CreateComplexTypeWithDefaultName(cpc);
            // add a copy of Entity properties to the ComplexType
            var copyCmd      = new CopyPropertiesCommand(new PropertiesClipboardFormat(_properties), _createdComplexType);
            var propertyName = ModelHelper.GetUniqueConceptualPropertyName(
                ComplexConceptualProperty.DefaultComplexPropertyName, _entityType);
            // add a new Property of created ComplexType to the Entity
            var createCPCmd = new CreateComplexPropertyCommand(propertyName, _entityType, _createdComplexType);
            var cp          = new CommandProcessor(cpc, copyCmd, createCPCmd);

            cp.Invoke();
            _createdComplexProperty = createCPCmd.Property;

            // preserve mappings
            foreach (var property in _properties)
            {
                if (property is ComplexConceptualProperty)
                {
                    var createdComplexTypeProperty =
                        _createdComplexType.FindPropertyByLocalName(property.LocalName.Value) as ComplexConceptualProperty;
                    Debug.Assert(createdComplexTypeProperty != null, "Copied complex property not found");
                    if (createdComplexTypeProperty != null)
                    {
                        foreach (var complexPropertyMapping in property.GetAntiDependenciesOfType <ComplexProperty>())
                        {
                            PreserveComplexPropertyMapping(cpc, complexPropertyMapping, createdComplexTypeProperty);
                        }

                        foreach (var fcp in property.GetAntiDependenciesOfType <FunctionComplexProperty>())
                        {
                            PreserveFunctionComplexPropertyMapping(cpc, fcp, createdComplexTypeProperty);
                        }
                    }
                }
                else
                {
                    var createdComplexTypeProperty = _createdComplexType.FindPropertyByLocalName(property.LocalName.Value);
                    Debug.Assert(createdComplexTypeProperty != null, "Copied property not found");
                    if (createdComplexTypeProperty != null)
                    {
                        // update EntityTypeMappings
                        foreach (var scalarPropertyMapping in property.GetAntiDependenciesOfType <ScalarProperty>())
                        {
                            PreserveScalarPropertyMapping(cpc, scalarPropertyMapping, createdComplexTypeProperty);
                        }

                        // update ModificationFunctionMappings
                        foreach (var fsp in property.GetAntiDependenciesOfType <FunctionScalarProperty>())
                        {
                            PreserveFunctionScalarPropertyMapping(cpc, fsp, createdComplexTypeProperty);
                        }
                    }
                }
            }
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // first create new ComplexType
            _createdComplexType = CreateComplexTypeCommand.CreateComplexTypeWithDefaultName(cpc);
            // add a copy of Entity properties to the ComplexType
            var copyCmd = new CopyPropertiesCommand(new PropertiesClipboardFormat(_properties), _createdComplexType);
            var propertyName = ModelHelper.GetUniqueConceptualPropertyName(
                ComplexConceptualProperty.DefaultComplexPropertyName, _entityType);
            // add a new Property of created ComplexType to the Entity
            var createCPCmd = new CreateComplexPropertyCommand(propertyName, _entityType, _createdComplexType);
            var cp = new CommandProcessor(cpc, copyCmd, createCPCmd);
            cp.Invoke();
            _createdComplexProperty = createCPCmd.Property;

            // preserve mappings
            foreach (var property in _properties)
            {
                if (property is ComplexConceptualProperty)
                {
                    var createdComplexTypeProperty =
                        _createdComplexType.FindPropertyByLocalName(property.LocalName.Value) as ComplexConceptualProperty;
                    Debug.Assert(createdComplexTypeProperty != null, "Copied complex property not found");
                    if (createdComplexTypeProperty != null)
                    {
                        foreach (var complexPropertyMapping in property.GetAntiDependenciesOfType<ComplexProperty>())
                        {
                            PreserveComplexPropertyMapping(cpc, complexPropertyMapping, createdComplexTypeProperty);
                        }

                        foreach (var fcp in property.GetAntiDependenciesOfType<FunctionComplexProperty>())
                        {
                            PreserveFunctionComplexPropertyMapping(cpc, fcp, createdComplexTypeProperty);
                        }
                    }
                }
                else
                {
                    var createdComplexTypeProperty = _createdComplexType.FindPropertyByLocalName(property.LocalName.Value);
                    Debug.Assert(createdComplexTypeProperty != null, "Copied property not found");
                    if (createdComplexTypeProperty != null)
                    {
                        // update EntityTypeMappings
                        foreach (var scalarPropertyMapping in property.GetAntiDependenciesOfType<ScalarProperty>())
                        {
                            PreserveScalarPropertyMapping(cpc, scalarPropertyMapping, createdComplexTypeProperty);
                        }

                        // update ModificationFunctionMappings
                        foreach (var fsp in property.GetAntiDependenciesOfType<FunctionScalarProperty>())
                        {
                            PreserveFunctionScalarPropertyMapping(cpc, fsp, createdComplexTypeProperty);
                        }
                    }
                }
            }
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // create copy of the ComplexType
            var cmd = new CreateComplexTypeCommand(_clipboardComplexType.Name, true);
            CommandProcessor.InvokeSingleCommand(cpc, cmd);
            _createdComplexType = cmd.ComplexType;

            // copy child properties
            var cmd2 = new CopyPropertiesCommand(_clipboardComplexType.Properties, _createdComplexType);
            CommandProcessor.InvokeSingleCommand(cpc, cmd2);
            AddAnnotations(_clipboardComplexType, _createdComplexType);
        }
Exemple #4
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // create copy of the ComplexType
            var cmd = new CreateComplexTypeCommand(_clipboardComplexType.Name, true);

            CommandProcessor.InvokeSingleCommand(cpc, cmd);
            _createdComplexType = cmd.ComplexType;

            // copy child properties
            var cmd2 = new CopyPropertiesCommand(_clipboardComplexType.Properties, _createdComplexType);

            CommandProcessor.InvokeSingleCommand(cpc, cmd2);
            AddAnnotations(_clipboardComplexType, _createdComplexType);
        }