src/Misc/EFTools/EntityDesignModel/Commands/UpdateConceptualAndMappingModelsCommand.cs
/// <summary>
///     Creates a new EntitySetMapping in the existing EntityContainerMapping
///     based on another EntitySetMapping (esmToClone) in a different artifact.
///     Uses the FindMatchingEntityTypeInExistingArtifact() to match EntityTypes
///     within the EntitySetMapping.
/// </summary>
Creates a new EntitySetMapping in the existing EntityContainerMapping
based on another EntitySetMapping (esmToClone) in a different artifact.
Creates a new EntitySetMapping in the existing EntityContainerMapping based on another EntitySetMapping ( esmToClone ) in a different artifact .
private EntitySetMapping CloneEntitySetMapping(
            CommandProcessorContext cpc, EntitySetMapping esmToClone,
            EntityContainerMapping existingEntityContainerMapping, ConceptualEntitySet existingEntitySet,
            Dictionary<EntityType, EntityType> tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact)
        {
            var createESM = new CreateEntitySetMappingCommand(existingEntityContainerMapping, existingEntitySet);
            CommandProcessor.InvokeSingleCommand(cpc, createESM);
            var esm = createESM.EntitySetMapping;
            foreach (var etmToBeCloned in esmToClone.EntityTypeMappings())
            {
                var bindings = etmToBeCloned.TypeName.Bindings;
                if (bindings.Count != 1)
                {
                    Debug.Fail(
                        "EntityTypeMapping to be cloned " + etmToBeCloned.ToPrettyString() +
                        " has bindings count = " + bindings.Count + ". We only support 1 binding.");
                }
                else
                {
                    var b = bindings.First();
                    var etToBeCloned = b.Target as ConceptualEntityType;
                    Debug.Assert(etToBeCloned != null, "EntityType target of binding is not ConceptualEntityType");
                    var etInExistingArtifact =
                        FindMatchingConceptualEntityTypeInExistingArtifact(
                            etToBeCloned,
                            tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact);
                    if (null != etInExistingArtifact)
                    {
                        CreateEntityTypeMappingCommand.CloneEntityTypeMapping(
                            cpc,
                            etmToBeCloned,
                            esm,
                            etInExistingArtifact,
                            etmToBeCloned.Kind);
                    }
                    else
                    {
                        throw new UpdateModelFromDatabaseException(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                Resources.UpdateFromDatabaseEntitySetMappingCannotFindEntityType,
                                etToBeCloned.ToPrettyString()));
                    }
                }
            }
            return esm;
        }
private EntitySetMapping CloneEntitySetMapping ( CommandProcessorContext cpc , EntitySetMapping esmToClone , EntityContainerMapping existingEntityContainerMapping , ConceptualEntitySet existingEntitySet , Dictionary < EntityType , EntityType > tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact ) { var createESM = new CreateEntitySetMappingCommand ( existingEntityContainerMapping , existingEntitySet ) ; CommandProcessor . InvokeSingleCommand ( cpc , createESM ) ; var esm = createESM . EntitySetMapping ; foreach ( var etmToBeCloned in esmToClone . EntityTypeMappings ( ) ) { var bindings = etmToBeCloned . TypeName . Bindings ; if ( bindings . Count != 1 ) { Debug . Fail ( " " + etmToBeCloned . ToPrettyString ( ) + " " + bindings . Count + " " ) ; } else { var b = bindings . First ( ) ; var etToBeCloned = b . Target as ConceptualEntityType ; Debug . Assert ( etToBeCloned != null , " " ) ; var etInExistingArtifact = FindMatchingConceptualEntityTypeInExistingArtifact ( etToBeCloned , tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact ) ; if ( null != etInExistingArtifact ) { CreateEntityTypeMappingCommand . CloneEntityTypeMapping ( cpc , etmToBeCloned , esm , etInExistingArtifact , etmToBeCloned . Kind ) ; } else { throw new UpdateModelFromDatabaseException ( string . Format ( CultureInfo . CurrentCulture , Resources . UpdateFromDatabaseEntitySetMappingCannotFindEntityType , etToBeCloned . ToPrettyString ( ) ) ) ; } } } return esm ; }
Creates a new EntitySetMapping in the existing EntityContainerMapping
based on another EntitySetMapping (esmToClone) in a different artifact.
Creates a new EntitySetMapping in the existing EntityContainerMapping based on another EntitySetMapping ( esmToClone ) in a different artifact .
cpc
CommandProcessorContext
esmToClone
EntitySetMapping
existingEntityContainerMapping
EntityContainerMapping
existingEntitySet
ConceptualEntitySet
tempArtifactCEntityTypeToNewCEntityTypeInExistingArtifact
Dictionary<EntityType, EntityType>