src/Misc/EFTools/EntityDesignModel/Commands/UpdateConceptualAndMappingModelsCommand.cs
/// <summary>
///     Creates a new AssociationSetMapping in the existing EntityContainerMapping
///     based on another AssociationSetMapping (asmToClone) in a different artifact.
///     All the other parameters are presumed to already exist in the same artifact
///     as the EntityContainerMapping.
/// </summary>
Creates a new AssociationSetMapping in the existing EntityContainerMapping
based on another AssociationSetMapping (asmToClone) in a different artifact.
All the other parameters are presumed to already exist in the same artifact
as the EntityContainerMapping.
Creates a new AssociationSetMapping in the existing EntityContainerMapping based on another AssociationSetMapping ( asmToClone ) in a different artifact . All the other parameters are presumed to already exist in the same artifact as the EntityContainerMapping .
private AssociationSetMapping CloneAssociationSetMapping(
            CommandProcessorContext cpc, AssociationSetMapping asmToClone,
            EntityContainerMapping existingEntityContainerMapping, AssociationSet existingAssociationSet,
            Association existingAssociation, StorageEntitySet existingStorageEntitySet,
            Dictionary<EntityType, EntityType> tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact)
        {
            var createASM = new CreateAssociationSetMappingCommand(
                existingEntityContainerMapping, existingAssociationSet, existingAssociation, existingStorageEntitySet);
            CommandProcessor.InvokeSingleCommand(cpc, createASM);
            var asmInExistingArtifact = createASM.AssociationSetMapping;
            if (null == asmInExistingArtifact)
            {
                throw new UpdateModelFromDatabaseException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.UpdateFromDatabaseCannotCreateAssociationSetMapping,
                        existingAssociationSet.ToPrettyString()));
            }
            var existingAssocSetEnds = existingAssociationSet.AssociationSetEnds().ToArray();
            if (2 != existingAssocSetEnds.Length)
            {
                throw new UpdateModelFromDatabaseException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.UpdateFromDatabaseAssociationSetMappingWrongNumberAssociationSetEnds,
                        existingAssociationSet.ToPrettyString(),
                        existingAssocSetEnds.Length));
            }
            var endsToClone = asmToClone.EndProperties().ToArray();
            if (2 != endsToClone.Length)
            {
                throw new UpdateModelFromDatabaseException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.UpdateFromDatabaseAssociationSetMappingWrongNumberAssociationSetEnds,
                        existingAssociationSet.ToPrettyString(),
                        existingAssocSetEnds.Length));
            }
            for (var i = 0; i < 2; i++)
            {
                var aseInExistingArtifact = existingAssocSetEnds[i];
                var endToClone = endsToClone[i];
                CloneEndProperty(
                    cpc, endToClone, asmInExistingArtifact, aseInExistingArtifact, tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact);
            }
            return asmInExistingArtifact;
        }
private AssociationSetMapping CloneAssociationSetMapping ( CommandProcessorContext cpc , AssociationSetMapping asmToClone , EntityContainerMapping existingEntityContainerMapping , AssociationSet existingAssociationSet , Association existingAssociation , StorageEntitySet existingStorageEntitySet , Dictionary < EntityType , EntityType > tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact ) { var createASM = new CreateAssociationSetMappingCommand ( existingEntityContainerMapping , existingAssociationSet , existingAssociation , existingStorageEntitySet ) ; CommandProcessor . InvokeSingleCommand ( cpc , createASM ) ; var asmInExistingArtifact = createASM . AssociationSetMapping ; if ( null == asmInExistingArtifact ) { throw new UpdateModelFromDatabaseException ( string . Format ( CultureInfo . CurrentCulture , Resources . UpdateFromDatabaseCannotCreateAssociationSetMapping , existingAssociationSet . ToPrettyString ( ) ) ) ; } var existingAssocSetEnds = existingAssociationSet . AssociationSetEnds ( ) . ToArray ( ) ; if ( 2 != existingAssocSetEnds . Length ) { throw new UpdateModelFromDatabaseException ( string . Format ( CultureInfo . CurrentCulture , Resources . UpdateFromDatabaseAssociationSetMappingWrongNumberAssociationSetEnds , existingAssociationSet . ToPrettyString ( ) , existingAssocSetEnds . Length ) ) ; } var endsToClone = asmToClone . EndProperties ( ) . ToArray ( ) ; if ( 2 != endsToClone . Length ) { throw new UpdateModelFromDatabaseException ( string . Format ( CultureInfo . CurrentCulture , Resources . UpdateFromDatabaseAssociationSetMappingWrongNumberAssociationSetEnds , existingAssociationSet . ToPrettyString ( ) , existingAssocSetEnds . Length ) ) ; } for ( var i = 0 ; i < 2 ; i ++ ) { var aseInExistingArtifact = existingAssocSetEnds [ i ] ; var endToClone = endsToClone [ i ] ; CloneEndProperty ( cpc , endToClone , asmInExistingArtifact , aseInExistingArtifact , tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact ) ; } return asmInExistingArtifact ; }
Creates a new AssociationSetMapping in the existing EntityContainerMapping
based on another AssociationSetMapping (asmToClone) in a different artifact.
Creates a new AssociationSetMapping in the existing EntityContainerMapping based on another AssociationSetMapping ( asmToClone ) in a different artifact .
// cannot just look for an AssociationSetEnd with the same Role name in // the existing artifact as the role may have changed when the Association was // copied into the existing artifact - but we do know the ends were created in  // the same order - so simply match them up
cpc
CommandProcessorContext
asmToClone
AssociationSetMapping
existingEntityContainerMapping
EntityContainerMapping
existingAssociationSet
AssociationSet
existingAssociation
Association
existingStorageEntitySet
StorageEntitySet
tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact
Dictionary<EntityType, EntityType>