Esempio n. 1
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if the DesignerInfoPropertySet doesn't exist then we need to create it.
            if (_designerInfo.PropertySet == null)
            {
                _designerInfo.PropertySet = new DesignerInfoPropertySet(_designerInfo, null);
            }

            // if the DesignerProperty doesn't exist then we need to create it.
            DesignerProperty designerProperty;

            if (!_designerInfo.PropertySet.TryGetDesignerProperty(_name, out designerProperty))
            {
                designerProperty = new DesignerProperty(_designerInfo.PropertySet, null);
                designerProperty.LocalName.Value = _name;
                _designerInfo.PropertySet.AddDesignerProperty(_name, designerProperty);
            }

            // First let's check make sure any non-valid values are caught up the stack
            if (!designerProperty.ValueAttr.IsValidValue(_value))
            {
                throw new CommandValidationFailedException(
                          String.Format(CultureInfo.CurrentCulture, Resources.NonValidDesignerProperty, _value, _name));
            }

            // now we update the value of the designer property
            var cmdUpdateDefaultableValue = new UpdateDefaultableValueCommand <string>(designerProperty.ValueAttr, _value);

            CommandProcessor.InvokeSingleCommand(cpc, cmdUpdateDefaultableValue);

            // normalize and resolve the entire DesignerInfo
            XmlModelHelper.NormalizeAndResolve(_designerInfo);
        }
Esempio n. 2
0
        internal EntityTypeMapping Clone(EntitySetMapping newEntitySetMapping)
        {
            // here we clone the entity type mapping, instead of re-parenting it
            // this works around an XML editor bug where re-parenting an element causes asserts

            // first create the new XElement
            var tempDoc        = XDocument.Parse(XElement.ToString(SaveOptions.None), LoadOptions.None);
            var newetmXElement = tempDoc.Root;

            newetmXElement.Remove();
            // format the XML we just parsed
            Utils.FormatXML(newetmXElement, newEntitySetMapping.GetIndentLevel() + 1);

            // create the EntityTypeMapping & hook in it's xml.
            var newetm = new EntityTypeMapping(newEntitySetMapping, newetmXElement);

            newetm.AddXElementToParent(newetmXElement);

            // parse & Resolve the new EntityTypeMapping
            newetm.Parse(new HashSet <XName>());
            XmlModelHelper.NormalizeAndResolve(newetm);

            // add it to new EntitySetMapping
            newEntitySetMapping.AddEntityTypeMapping(newetm);

            return(newetm);
        }
Esempio n. 3
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // check that we have an existing artifact
            var service          = cpc.EditingContext.GetEFArtifactService();
            var existingArtifact = service.Artifact as EntityDesignArtifact;

            if (null == existingArtifact)
            {
                Debug.Fail("Null Artifact in ReplaceSsdlCommand.InvokeInternal()");
                return;
            }

            // replace the old SSDL with the new
            ReplaceSsdl(cpc, existingArtifact, _newSsdlReader);

            // replace the old MSL with the new
            ReplaceMsl(cpc, existingArtifact, _newMslReader);

            // normalize and resolve the StorageModel
            XmlModelHelper.NormalizeAndResolve(existingArtifact.StorageModel);
            Debug.Assert(EFElementState.Resolved == existingArtifact.StorageModel.State, "StorageModel State should be Resolved");

            // normalize and resolve the MappingModel
            XmlModelHelper.NormalizeAndResolve(existingArtifact.MappingModel);
            Debug.Assert(EFElementState.Resolved == existingArtifact.MappingModel.State, "MappingModel State should be Resolved");
        }
Esempio n. 4
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            Debug.Assert(_binding != null, "InvokeInternal is called when _binding is null.");
            if (_binding == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when _binding is null");
            }

            // set new values in if we were sent them
            if (_entityProperty != null &&
                _binding.Name.Target != _entityProperty)
            {
                _binding.Name.SetRefName(_entityProperty);
            }

            // set new values in if we were sent them
            if (_columnName != null &&
                !string.Equals(_binding.ColumnName.Value, _columnName, StringComparison.CurrentCulture))
            {
                _binding.ColumnName.Value = _columnName;
            }

            XmlModelHelper.NormalizeAndResolve(_binding);
        }
Esempio n. 5
0
        private static FunctionComplexProperty CreateNewFunctionComplexProperty(EFElement parent, ComplexConceptualProperty property)
        {
            Debug.Assert(property != null,
                         "CreateFunctionComplexPropertyCommand.CreateNewFunctionComplexProperty() received null property");
            Debug.Assert
                (property.ComplexType.Target != null,
                typeof(CreateFunctionComplexPropertyCommand).Name
                + ".CreateNewFunctionComplexProperty() received property with null ComplexType.Target");

            // actually create it in the XLinq tree
            var fcp = new FunctionComplexProperty(parent, null);

            fcp.Name.SetRefName(property);
            fcp.TypeName.SetRefName(property.ComplexType.Target);

            XmlModelHelper.NormalizeAndResolve(fcp);

            if (fcp == null)
            {
                throw new ItemCreationFailureException();
            }

            Debug.Assert(
                fcp.Name.Target != null && fcp.Name.Target.LocalName.Value == fcp.Name.RefName,
                (fcp.Name.Target == null
                     ? "Broken property resolution for FunctionComplexProperty " + fcp.ToPrettyString() + ": null Target"
                     : "Broken property resolution for FunctionComplexProperty " + fcp.ToPrettyString() + ": Target.LocalName = "
                 + fcp.Name.Target.LocalName.Value + ", RefName = " + fcp.Name.RefName));

            return(fcp);
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var cp = new CommandProcessor(cpc);
            CreateFunctionComplexPropertyCommand preReqCmd = null;

            for (var i = 0; i < _propertyChain.Count; i++)
            {
                var property = _propertyChain[i];
                Debug.Assert(property.EntityModel.IsCSDL, "Each Property in the chain must be in the CSDL");
                var complexConceptualProperty = property as ComplexConceptualProperty;
                if (complexConceptualProperty != null)
                {
                    Debug.Assert(i < _propertyChain.Count - 1, "Last property shouldn't be ComplexConceptualProperty");
                    CreateFunctionComplexPropertyCommand cmd = null;
                    if (preReqCmd == null)
                    {
                        // first property has a mapping whose parent is the ModificationFunction itself
                        cmd = new CreateFunctionComplexPropertyCommand(_modificationFunction, complexConceptualProperty);
                    }
                    else
                    {
                        // later properties have a mapping whose parent is the ComplexProperty produced from the previous command
                        cmd = new CreateFunctionComplexPropertyCommand(preReqCmd, complexConceptualProperty);
                    }

                    // set up the prereq Command to use for next time around this loop and for the
                    // CreateFunctionScalarPropertyCommand below
                    preReqCmd = cmd;

                    // enqueue the command
                    cp.EnqueueCommand(cmd);
                }
                else
                {
                    Debug.Assert(i == _propertyChain.Count - 1, "This should be the last property");

                    CreateFunctionScalarPropertyCommand cmd = null;
                    if (preReqCmd == null)
                    {
                        // create the FunctionScalarProperty command without any other properties in the property chain
                        cmd = new CreateFunctionScalarPropertyCommand(
                            _modificationFunction, property, _navPropPointingToProperty, _parameter, _version);
                    }
                    else
                    {
                        // create the FunctionScalarProperty command using the command for the previous property in the property chain
                        cmd = new CreateFunctionScalarPropertyCommand(preReqCmd, property, _navPropPointingToProperty, _parameter, _version);
                    }

                    cp.EnqueueCommand(cmd);
                    cp.Invoke();
                    _createdProperty = cmd.FunctionScalarProperty;
                    if (_createdProperty != null)
                    {
                        XmlModelHelper.NormalizeAndResolve(_createdProperty);
                    }
                    return;
                }
            }
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if don't have an ECM yet, go create one
            if (_entityContainerMapping == null)
            {
                var cmd = new CreateEntityContainerMappingCommand(_entitySet.Artifact);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);

                _entityContainerMapping = cmd.EntityContainerMapping;
            }

            Debug.Assert(_entityContainerMapping != null, "_entityContainerMapping should not be null");
            if (_entityContainerMapping == null)
            {
                throw new CannotLocateParentItemException();
            }

            // create the ESM
            var esm = new EntitySetMapping(_entityContainerMapping, null);

            esm.Name.SetRefName(_entitySet);
            _entityContainerMapping.AddEntitySetMapping(esm);

            XmlModelHelper.NormalizeAndResolve(esm);

            _created = esm;
        }
Esempio n. 8
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var nExistingTypeShapeCount =
                _entity.GetAntiDependenciesOfType <EntityTypeShape>().Count(ets => ets.Diagram.Id == _diagram.Id.Value);

            Debug.Assert(
                nExistingTypeShapeCount == 0,
                "There is already Entity Type Shape for entity :" + _entity.Name + " in the diagram " + _diagram.Name);

            if (nExistingTypeShapeCount == 0)
            {
                var shape = new EntityTypeShape(_diagram, null);
                _diagram.AddEntityTypeShape(shape);

                shape.EntityType.SetRefName(_entity);
                shape.Width.Value = DEFAULTWIDTH;

                // The DSL will set the correct locations for the shapes at a later point, but we need to provide initial values for X and Y in the meantime
                // so that we can construct the shape. We're using random numbers here to ensure that if the DSL fails for some reason, new shapes do not
                // stack directly on top of each other.
                shape.PointX.Value = _rand.NextDouble() * 12.0;
                shape.PointY.Value = _rand.NextDouble() * 32.0;

                if (_fillColor != EntityDesignerDiagramConstant.EntityTypeShapeDefaultFillColor)
                {
                    shape.FillColor.Value = _fillColor;
                }

                XmlModelHelper.NormalizeAndResolve(shape);

                _created = shape;
            }
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var associationSetMapping = ModelHelper.FindAssociationSetMappingForConceptualAssociation(Association);

            if (associationSetMapping == null)
            {
                // This AssociationSetMapping does not exist, create it
                base.InvokeInternal(cpc);
                associationSetMapping = AssociationSetMapping;
                Debug.Assert(associationSetMapping != null, "Could not create AssociationSetMapping");
            }
            else
            {
                // The AssociationSetMapping already exists, update it
                associationSetMapping.Name.SetRefName(AssociationSet);
                associationSetMapping.TypeName.SetRefName(Association);
                associationSetMapping.StoreEntitySet.SetRefName(StorageEntitySet);

                XmlModelHelper.NormalizeAndResolve(associationSetMapping);

                Debug.Assert(associationSetMapping.Name.Target != null, "Could not resolve association set reference");
                Debug.Assert(associationSetMapping.TypeName.Target != null, "Could not resolve association type reference");
                Debug.Assert(associationSetMapping.StoreEntitySet.Target != null, "Could not resolve table reference");

                InferReferentialConstraints.AddRule(cpc, Association);
            }
        }
Esempio n. 10
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            Debug.Assert(cpc != null, "InvokeInternal is called when EntityContainerMapping is null.");

            // safety check, this should never be hit
            if (EntityType == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when entity type is null");
            }

            EntityType.Abstract.Value = SetAbstract;

            // remove any function mappings if we are setting this to abstract
            if (SetAbstract)
            {
                var etms = new List <EntityTypeMapping>();
                etms.AddRange(EntityType.GetAntiDependenciesOfType <EntityTypeMapping>());

                for (var i = etms.Count - 1; i >= 0; i--)
                {
                    var etm = etms[i];
                    if (etm != null &&
                        etm.Kind == EntityTypeMappingKind.Function)
                    {
                        DeleteEFElementCommand.DeleteInTransaction(cpc, etm);
                    }
                }
            }

            XmlModelHelper.NormalizeAndResolve(EntityType);
        }
Esempio n. 11
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            try
            {
                // check that we have an existing artifact
                var service          = cpc.EditingContext.GetEFArtifactService();
                var existingArtifact = service.Artifact as EntityDesignArtifact;
                Debug.Assert(existingArtifact != null, "Null Artifact in ReplaceCsdlAndMslCommand.InvokeInternal()");
                if (null == existingArtifact)
                {
                    return;
                }

                // replace the old CSDL with the new
                ReplaceCsdl(cpc, existingArtifact, _newCsdlReader);

                // replace the old MSL with the new
                ReplaceMsl(cpc, existingArtifact, _newMslReader);

                // normalize and resolve the ConceptualModel
                XmlModelHelper.NormalizeAndResolve(existingArtifact.ConceptualModel);
                Debug.Assert(EFElementState.Resolved == existingArtifact.ConceptualModel.State, "ConceptualModel State should be Resolved");

                // normalize and resolve the MappingModel
                XmlModelHelper.NormalizeAndResolve(existingArtifact.MappingModel);
                Debug.Assert(EFElementState.Resolved == existingArtifact.MappingModel.State, "MappingModel State should be Resolved");
            }
            finally
            {
                Cleanup();
            }
        }
Esempio n. 12
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            if (_entityProperty != null)
            {
                Debug.Assert(_entityProperty.EntityModel.IsCSDL, "_entityProperty should be from C-side model");
                ScalarProperty.Name.SetRefName(_entityProperty);
            }

            if (TableColumn != null)
            {
                Debug.Assert(TableColumn.EntityModel.IsCSDL != true, "_tableColumn should not be from C-side model");
                ScalarProperty.ColumnName.SetRefName(TableColumn);
            }

            XmlModelHelper.NormalizeAndResolve(ScalarProperty);

            // if we change a scalar in an association mapping, make sure that we still have good MSL
            if (ScalarProperty.EndProperty != null)
            {
                var asm = ScalarProperty.EndProperty.Parent as AssociationSetMapping;
                Debug.Assert(asm != null, "_sp.EndProperty parent is not an AssociationSetMapping");
                if (asm != null)
                {
                    EnforceAssociationSetMappingRules.AddRule(cpc, asm);

                    var assoc = asm.TypeName.Target;
                    Debug.Assert(assoc != null, "Could not resolve association reference");
                    if (assoc != null)
                    {
                        InferReferentialConstraints.AddRule(cpc, assoc);
                    }
                }
            }
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            if (!string.IsNullOrEmpty(Role) &&
                !string.Equals(End.Role.Value, Role, StringComparison.Ordinal))
            {
                // TODO:  should this command be enqueued in the command processor?
                RenameCommand c = new EntityDesignRenameCommand(End, Role, true);
                CommandProcessor.InvokeSingleCommand(cpc, c);

                // bug 563525: we need to update EndProperties within AssociationSetMappings if the AssociationEnd changes.
                // we update the "Role" of an AssociationSetEnd in the RenameCommand but the SingleItemBinding that we have to update
                // that is bound to the AssociationSetEnd is unique to this situation; it is not technically a "refactor rename".
                var associationSetEnd = End.GetAntiDependenciesOfType <AssociationSetEnd>().FirstOrDefault();

                if (associationSetEnd != null)
                {
                    // we need to renormalize the associationSetEnd, since the role name will have changed.
                    XmlModelHelper.NormalizeAndResolve(associationSetEnd);

                    var endPropertiesInAssocSetMappings = associationSetEnd.GetAntiDependenciesOfType <EndProperty>();
                    foreach (var endProperty in endPropertiesInAssocSetMappings)
                    {
                        endProperty.Name.SetRefName(associationSetEnd);
                        CheckArtifactBindings.ScheduleBindingsForRebind(cpc, new HashSet <ItemBinding> {
                            endProperty.Name
                        });
                    }
                }
            }
        }
Esempio n. 14
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var service  = cpc.EditingContext.GetEFArtifactService();
            var artifact = service.Artifact;

            var function = new Function(artifact.StorageModel(), null);

            function.Name.Value         = Name;
            function.Schema.Value       = SchemaName;
            function.IsComposable.Value = IsComposable;
            function.ReturnType.Value   = ReturnType;

            if (Name != StoreFunctionName)
            {
                function.StoreFunctionName.Value = StoreFunctionName;
            }

            foreach (var parameterInfo in ParameterInfos)
            {
                var parameter = new Parameter(function, null);
                parameter.Name.Value = parameterInfo.Name;
                parameter.Mode.Value = parameterInfo.Mode;
                parameter.Type.Value = parameterInfo.Type;
                function.AddParameter(parameter);
            }

            artifact.StorageModel().AddFunction(function);
            XmlModelHelper.NormalizeAndResolve(function);

            CreatedFunction = function;
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            if (String.IsNullOrEmpty(_longDescriptionText))
            {
                if (_efElement.Documentation != null &&
                    _efElement.Documentation.LongDescription != null)
                {
                    DeleteEFElementCommand.DeleteInTransaction(cpc, _efElement.Documentation.LongDescription);

                    // if the documentation node is empty, delete it
                    if (_efElement.Documentation.Summary == null)
                    {
                        DeleteEFElementCommand.DeleteInTransaction(cpc, _efElement.Documentation);
                    }
                }
            }
            else
            {
                if (_efElement.Documentation == null)
                {
                    _efElement.Documentation = new Documentation(_efElement, null);
                }

                if (_efElement.Documentation.LongDescription == null)
                {
                    _efElement.Documentation.LongDescription = new LongDescription(_efElement.Documentation, null);
                }

                _efElement.Documentation.LongDescription.Text = _longDescriptionText;

                XmlModelHelper.NormalizeAndResolve(_efElement);
            }
        }
Esempio n. 16
0
        private static void UpdateMappingModel(EFArtifact existingArtifact, string oldStorageEntityContainerName)
        {
            // replaces the possible reference to the old S-side EntityContainer name
            ReplaceMappingContainerRef(existingArtifact, oldStorageEntityContainerName);

            // normalize and resolve the changes we just made above
            XmlModelHelper.NormalizeAndResolve(existingArtifact.MappingModel());
        }
Esempio n. 17
0
 protected override void InvokeInternal(CommandProcessorContext cpc)
 {
     RetargetWithMetadataConverter(_artifact.XDocument, _targetSchemaVersion, MetadataConverterDriver.Instance);
     if (_reparseArtifact)
     {
         cpc.Artifact.Parse(new HashSet <XName>());
         XmlModelHelper.NormalizeAndResolve(cpc.Artifact);
     }
 }
Esempio n. 18
0
 protected override void PostInvoke(CommandProcessorContext cpc)
 {
     // Normalize EFContainer if necessary
     foreach (var item in _efContainerToBeNormalized)
     {
         XmlModelHelper.NormalizeAndResolve(item);
     }
     base.PostInvoke(cpc);
 }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // don't do anything if we are trying to set the same thing
            if (string.Compare(Condition.ColumnName.RefName, NewStorageProperty.LocalName.Value, StringComparison.CurrentCulture) != 0)
            {
                Condition.ColumnName.SetRefName(NewStorageProperty);
                XmlModelHelper.NormalizeAndResolve(Condition);

                EnforceEntitySetMappingRules.AddRule(cpc, Condition);
            }
        }
Esempio n. 20
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            Debug.Assert(cpc != null, "InvokeInternal is called when EntityContainerMapping is null.");
            if (_ecm == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when EntityContainerMapping is null.");
            }

            _ecm.GenerateUpdateViews.Value = _generateUpdateViews;
            XmlModelHelper.NormalizeAndResolve(_ecm);
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var associationConnector = new AssociationConnector(_diagram, null);

            _diagram.AddAssociationConnector(associationConnector);

            associationConnector.Association.SetRefName(_association);

            XmlModelHelper.NormalizeAndResolve(associationConnector);

            _created = associationConnector;
        }
 protected override void InvokeInternal(CommandProcessorContext cpc)
 {
     // if the OnDeleteAction already exists then only change the action value
     _createdAction = _parentEnd.OnDeleteAction;
     if (_createdAction == null)
     {
         _createdAction            = new OnDeleteAction(_parentEnd, null);
         _parentEnd.OnDeleteAction = _createdAction;
     }
     _createdAction.Action.Value = _action;
     XmlModelHelper.NormalizeAndResolve(_createdAction);
 }
Esempio n. 23
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var end = new EndProperty(AssociationSetMapping, null);

            end.Name.SetRefName(AssociationSetEnd);
            AssociationSetMapping.AddEndProperty(end);

            XmlModelHelper.NormalizeAndResolve(end);

            Debug.Assert(end.Name.Target != null, "Could not resolve AssociationSetEnd in an EndProperty");
            _created = end;
        }
Esempio n. 24
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var inheritanceConnector = new InheritanceConnector(_diagram, null);

            _diagram.AddInheritanceConnector(inheritanceConnector);

            inheritanceConnector.EntityType.SetRefName(_entity);

            XmlModelHelper.NormalizeAndResolve(inheritanceConnector);

            _created = inheritanceConnector;
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // make sure that there isn't an ETM of this kind already
            var entityTypeMapping = ModelHelper.FindEntityTypeMapping(cpc, _entityType, _kind, false);

            Debug.Assert(entityTypeMapping == null, "We are calling CreateEntityTypeMappingCommand and there is already one of this Kind");
            if (entityTypeMapping != null)
            {
                _created = entityTypeMapping;
                return;
            }

            // see if we can get the EntitySetMapping for our entity (if we weren't passed it)
            if (_entitySetMapping == null)
            {
                var ces = _entityType.EntitySet as ConceptualEntitySet;
                Debug.Assert(ces != null, "_entityType.EntitySet should be a ConceptualEntitySet");

                // find the EntitySetMapping for this type (V1 assumption is that there is only ESM per ES)
                EntitySetMapping esm = null;
                foreach (var depMapping in ces.GetAntiDependenciesOfType <EntitySetMapping>())
                {
                    esm = depMapping;
                    break;
                }

                _entitySetMapping = esm;
            }

            // if we still don't have an ESM, create one
            if (_entitySetMapping == null)
            {
                var cmd = new CreateEntitySetMappingCommand(
                    _entityType.Artifact.MappingModel().FirstEntityContainerMapping,
                    _entityType.EntitySet as ConceptualEntitySet);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
                _entitySetMapping = cmd.EntitySetMapping;
            }
            Debug.Assert(
                _entitySetMapping != null,
                "_entitySetMapping should not be null - we have been unable to find or create an EntitySetMapping");

            // create the ETM
            var etm = new EntityTypeMapping(_entitySetMapping, null, _kind);

            etm.TypeName.SetRefName(_entityType);
            _entitySetMapping.AddEntityTypeMapping(etm);

            XmlModelHelper.NormalizeAndResolve(etm);

            _created = etm;
        }
Esempio n. 26
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var service  = cpc.EditingContext.GetEFArtifactService();
            var artifact = service.Artifact;

            // the model that we want to add the entity to
            var model = ModelHelper.GetEntityModel(artifact, ModelSpaceValue);

            if (model == null)
            {
                throw new CannotLocateParentItemException();
            }

            // check for uniqueness
            if (UniquifyName)
            {
                Name = ModelHelper.GetUniqueName(typeof(EntityType), model, Name);
            }
            else
            {
                string msg = null;
                if (ModelHelper.IsUniqueName(typeof(EntityType), model, Name, false, out msg) == false)
                {
                    throw new CommandValidationFailedException(msg);
                }
            }

            // create the new item in our model
            EntityType entity = null;

            if (model.IsCSDL)
            {
                entity = new ConceptualEntityType(model as ConceptualEntityModel, null);
            }
            else
            {
                entity = new StorageEntityType(model as StorageEntityModel, null);
            }
            Debug.Assert(entity != null, "entity should not be null");
            if (entity == null)
            {
                throw new ItemCreationFailureException();
            }

            // set the name, add it to the parent item
            entity.LocalName.Value = Name;
            model.AddEntityType(entity);

            XmlModelHelper.NormalizeAndResolve(entity);

            CreatedEntityType = entity;
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // we allow the command to set null _endpoints if needed.
            var navProp1 = new NavigationProperty(Entity, null);

            navProp1.LocalName.Value = Name;
            navProp1.Relationship.SetRefName(Association);
            navProp1.FromRole.SetRefName(FromEnd);
            navProp1.ToRole.SetRefName(ToEnd);
            Entity.AddNavigationProperty(navProp1);
            _createdNavigationProperty = navProp1;
            XmlModelHelper.NormalizeAndResolve(navProp1);
        }
Esempio n. 28
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var cond = new Condition(_associationSetMapping, null);

            cond.ColumnName.SetRefName(_tableColumn);
            _associationSetMapping.AddCondition(cond);

            ModelHelper.SetConditionPredicate(cond, _isNull, _conditionValue);

            XmlModelHelper.NormalizeAndResolve(cond);

            _created = cond;
        }
        internal Property CreateProperty()
        {
            var isNullable =
                Nullable != null
                    ? Nullable.Value ? BoolOrNone.TrueValue : BoolOrNone.FalseValue
                    : null;

            var property = CreateProperty(EntityType, Name, Type, isNullable, _insertPosition);

            EntityType.AddProperty(property);

            XmlModelHelper.NormalizeAndResolve(property);

            return(property);
        }
Esempio n. 30
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            Debug.Assert(
                _function != null && _functionImport != null, "InvokeInternal is called when _function or _function import is null.");
            if (_function == null ||
                _functionImport == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when _function or _function import is null.");
            }

            _fim = _functionImport.FunctionImportMapping;
            _fim.FunctionName.SetRefName(_function);

            XmlModelHelper.NormalizeAndResolve(_fim);
        }