コード例 #1
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);
                    }
                }
            }
        }
コード例 #2
0
        protected override void PreInvoke(CommandProcessorContext cpc)
        {
            if (ScalarProperty.MappingFragment != null)
            {
                EnforceEntitySetMappingRules.AddRule(cpc, ScalarProperty);

                MFConceptualEntityTypeName = ScalarProperty.FirstBoundConceptualEntityType != null
                                                 ? ScalarProperty.FirstBoundConceptualEntityType.Name.Value
                                                 : null;
                MFConceptualPropertyName = ScalarProperty.Name.Target != null ? ScalarProperty.Name.Target.Name.Value : null;
                MFStorageEntitySetName   = ScalarProperty.BoundStorageEntityType != null
                                             ? ScalarProperty.BoundStorageEntityType.Name.Value
                                             : null;
                MFStorageColumnName             = ScalarProperty.ColumnName.Target != null ? ScalarProperty.ColumnName.Target.Name.Value : null;
                MFConceptualEntityTypeOwnerName = ScalarProperty.FirstBoundConceptualEntityType != null
                                                      ? ScalarProperty.FirstBoundConceptualEntityType.Name.Value
                                                      : null;
                MFComplexParentList =
                    ScalarProperty.GetParentComplexProperties(true)
                    .Where(cp => cp.Name.Target != null)
                    .Select(cp => cp.Name.Target.Name.Value);
            }
            else if (ScalarProperty.EndProperty != null)
            {
                var asm = ScalarProperty.EndProperty.Parent as AssociationSetMapping;
                Debug.Assert(asm != null, "this.ScalarProperty.EndProperty.Parent should be an AssociationSetMapping");
                if (asm != null)
                {
                    EnforceAssociationSetMappingRules.AddRule(cpc, asm);

                    var assoc = asm.TypeName.Target;
                    Debug.Assert(assoc != null, "the association set mapping does not have an Association");
                    if (assoc != null)
                    {
                        InferReferentialConstraints.AddRule(cpc, assoc);
                    }
                }
            }

            // Also add the integrity check to propagate the StoreGeneratedPattern value to the
            // S-side (may be altered by property mapping being deleted) unless we are part
            // of an Update Model txn in which case there is no need as the whole artifact has
            // this integrity check applied by UpdateModelFromDatabaseCommand
            if (EfiTransactionOriginator.UpdateModelFromDatabaseId != cpc.OriginatorId &&
                ScalarProperty.Name != null &&
                ScalarProperty.Name.Target != null)
            {
                var cProp = ScalarProperty.Name.Target as ConceptualProperty;
                Debug.Assert(
                    cProp != null, "ScalarProperty should have Name target with type " + typeof(ConceptualProperty).Name +
                    ", instead got type " + ScalarProperty.Name.Target.GetType().FullName);
                if (cProp != null)
                {
                    PropagateStoreGeneratedPatternToStorageModel.AddRule(cpc, cProp, true);
                }
            }

            base.PreInvoke(cpc);
        }
コード例 #3
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            if (_endProperty == null)
            {
                var cmd = new CreateEndPropertyCommand(_associationSetMapping, _associationSetEnd);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
                _endProperty = cmd.EndProperty;
            }

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

            var sp = new ScalarProperty(_endProperty, null);

            sp.Name.SetRefName(_entityProperty);
            sp.ColumnName.SetRefName(_tableColumn);
            _endProperty.AddScalarProperty(sp);

            XmlModelHelper.NormalizeAndResolve(sp);

            if (_enforceConstraints)
            {
                var asm = _endProperty.Parent as AssociationSetMapping;
                Debug.Assert(asm != null, "_endProperty parent is not an AssociationSetMapping");
                EnforceAssociationSetMappingRules.AddRule(cpc, asm);

                var assoc = asm.TypeName.Target;
                Debug.Assert(assoc != null, "_endProperty parent has a null Association");
                if (assoc != null)
                {
                    InferReferentialConstraints.AddRule(cpc, assoc);
                }
            }

            _created = sp;
        }
コード例 #4
0
        protected override void PreInvoke(CommandProcessorContext cpc)
        {
            base.PreInvoke(cpc);

            OldRole         = End.Role.Value;
            OldMultiplicity = End.Multiplicity.Value;

            // Bug 599719: If this end's role equals the other end's role (within the association), we end up with the same normalized
            // names, and thus corrupt the symbol table. Attempts to rebind SingleItemBindings will corrupt the model. We have to
            // short-circuit the renaming here.
            var parentAssociation = End.Parent as Association;

            Debug.Assert(parentAssociation != null, "Where is the association for this association end?");
            if (parentAssociation != null)
            {
                var associationEnd = ModelHelper.FindAssociationEnd(parentAssociation, Role);
                if (associationEnd != null)
                {
                    var msg = String.Format(CultureInfo.CurrentCulture, Resources.Error_AssociationEndInAssocNotUnique, Role);
                    throw new CommandValidationFailedException(msg);
                }
            }

            if (string.IsNullOrEmpty(Multiplicity) == false &&
                !string.Equals(End.Multiplicity.Value, Multiplicity, StringComparison.OrdinalIgnoreCase))
            {
                End.Multiplicity.Value = Multiplicity;
                var association = End.Parent as Association;
                if (association != null &&
                    association.AssociationSet != null &&
                    association.AssociationSet.AssociationSetMapping != null)
                {
                    EnforceAssociationSetMappingRules.AddRule(cpc, association.AssociationSet.AssociationSetMapping);
                }
            }

            InferReferentialConstraints.AddRule(cpc, End.Parent as Association);
        }
コード例 #5
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            _property.Relationship.SetRefName(_association);
            _property.Relationship.Rebind();
            Debug.Assert(
                (_property.Relationship.Status == BindingStatus.Known ||
                 (_association == null && _property.Relationship.Status == BindingStatus.Undefined)),
                "Rebind for the NavigationProperty failed");

            if (_association != null)
            {
                if (_end1 == null ||
                    _end2 == null)
                {
                    var associationEnds = _association.AssociationEnds();
                    Debug.Assert(associationEnds.Count < 3, "AssociationEnds are >= 3");
                    _end1 =
                        associationEnds.Where(
                            r => r.Type != null && r.Type.Status == BindingStatus.Known && r.Type.Target == _property.Parent)
                        .FirstOrDefault();
                    _end2 = associationEnds.Where(
                        r => r.Type != null && r.Type.Status == BindingStatus.Known &&
                        ((r.Type.Target != _property.Parent) ||
                         (r.Type.Target == _property.Parent && r != _end1))).FirstOrDefault();
                }

                // updating association's multiplicity value as opposed to multiplicity itself.
                if (string.IsNullOrEmpty(_multiplicity) &&
                    _end2 != null)
                {
                    _multiplicity = _end2.Multiplicity.Value;
                }
            }
            else
            {
                // resets end points when we get a null association
                _end1 = null;
                _end2 = null;
            }

            // rebinds association properties.
            _property.FromRole.SetRefName(_end1);
            _property.FromRole.Rebind();
            _property.ToRole.SetRefName(_end2);
            _property.ToRole.Rebind();

            if (_property.ToRole.Status == BindingStatus.Known &&
                string.Compare(_property.ToRole.Target.Multiplicity.Value, _multiplicity, StringComparison.OrdinalIgnoreCase) != 0)
            {
                if (_property.Relationship.Status == BindingStatus.Known)
                {
                    var association = _property.Relationship.Target;

                    _property.ToRole.Target.Multiplicity.Value = _multiplicity;

                    if (association != null &&
                        association.AssociationSet != null &&
                        association.AssociationSet.AssociationSetMapping != null)
                    {
                        EnforceAssociationSetMappingRules.AddRule(cpc, association.AssociationSet.AssociationSetMapping);
                    }
                }
            }
        }