src/Misc/EFTools/EntityDesignEntityDesigner/CustomCode/Rules/EntityType_ChangeRule.cs
/// <summary>
///     Do the following when an EntityType changes:
///     - Update roles in related Associations
/// </summary>
/// <param name="e"></param>
Do the following when an EntityType changes:
Update roles in related Associations
Do the following when an EntityType changes : Update roles in related Associations
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            base.ElementPropertyChanged(e);
            if (e.ModelElement.IsDeleted
                || e.ModelElement.IsDeleting)
            {
                return;
            }
            var changedEntity = e.ModelElement as EntityType;
            Debug.Assert(changedEntity != null);
            Debug.Assert(changedEntity.EntityDesignerViewModel != null);
            if (changedEntity != null
                && changedEntity.EntityDesignerViewModel != null)
            {
                var viewModel = changedEntity.EntityDesignerViewModel;
                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null);
                if (tx != null
                    && !tx.IsSerializing)
                {
                    if (e.DomainProperty.Id == NameableItem.NameDomainPropertyId)
                    {
                        if (viewModel.ModelXRef.GetExisting(changedEntity) == null)
                        {
                            return;
                        }
                        if (!EscherAttributeContentValidator.IsValidCsdlEntityTypeName(changedEntity.Name))
                        {
                            throw new InvalidOperationException(
                                String.Format(CultureInfo.CurrentCulture, Resources.Error_EntityNameInvalid, changedEntity.Name));
                        }
                        if (ModelUtils.IsUniqueName(changedEntity, changedEntity.Name, viewModel.EditingContext) == false)
                        {
                            throw new InvalidOperationException(
                                String.Format(CultureInfo.CurrentCulture, Resources.Error_EntityNameDuplicate, changedEntity.Name));
                        }
                        ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new EntityTypeChange(changedEntity));
                    }
                }
            }
        }
public override void ElementPropertyChanged ( ElementPropertyChangedEventArgs e ) { base . ElementPropertyChanged ( e ) ; if ( e . ModelElement . IsDeleted || e . ModelElement . IsDeleting ) { return ; } var changedEntity = e . ModelElement as EntityType ; Debug . Assert ( changedEntity != null ) ; Debug . Assert ( changedEntity . EntityDesignerViewModel != null ) ; if ( changedEntity != null && changedEntity . EntityDesignerViewModel != null ) { var viewModel = changedEntity . EntityDesignerViewModel ; var tx = ModelUtils . GetCurrentTx ( e . ModelElement . Store ) ; Debug . Assert ( tx != null ) ; if ( tx != null && ! tx . IsSerializing ) { if ( e . DomainProperty . Id == NameableItem . NameDomainPropertyId ) { if ( viewModel . ModelXRef . GetExisting ( changedEntity ) == null ) { return ; } if ( ! EscherAttributeContentValidator . IsValidCsdlEntityTypeName ( changedEntity . Name ) ) { throw new InvalidOperationException ( String . Format ( CultureInfo . CurrentCulture , Resources . Error_EntityNameInvalid , changedEntity . Name ) ) ; } if ( ModelUtils . IsUniqueName ( changedEntity , changedEntity . Name , viewModel . EditingContext ) == false ) { throw new InvalidOperationException ( String . Format ( CultureInfo . CurrentCulture , Resources . Error_EntityNameDuplicate , changedEntity . Name ) ) ; } ViewModelChangeContext . GetNewOrExistingContext ( tx ) . ViewModelChanges . Add ( new EntityTypeChange ( changedEntity ) ) ; } } } }
Do the following when an EntityType changes:
 Update roles in related Associations
Do the following when an EntityType changes : Update roles in related Associations
// if the element is deleted or about to be deleted, this rule will get fired. // Just return immediately here because we don't care if the entity-type's property has changed. // don't do the auto update stuff if we are in the middle of deserialization // are they changing the name? // if we are creating this Entity, there is no 'change' to do
e
ElementPropertyChangedEventArgs
None