src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/ModelObjectItemWizard.cs
// <summary>
//     Creates commands to remove function imports and complex types corresponding to results if ones exist.
// </summary>
// <param name="designArtifact">Artifact.</param>
// <returns>IEnumerable of commands for deleting function imports and corresponding complex types.</returns>
// <remarks>
//     This function should be called only from RunFinished() method as we don't check whether complex types we
//     are removing are not used by other function imports or entities.
// </remarks>
Creates commands to remove function imports and complex types corresponding to results if ones exist.
Creates commands to remove function imports and complex types corresponding to results if ones exist .
private static IEnumerable<Command> CreateRemoveFunctionImportCommands(EntityDesignArtifact designArtifact)
        {
            var model = designArtifact.ConceptualModel;
            var cec = (ConceptualEntityContainer)model.FirstEntityContainer;
            foreach (var fi in cec.FunctionImports())
            {
                yield return fi.GetDeleteCommand();
                if (fi.IsReturnTypeComplexType)
                {
                    var complexType = model.ComplexTypes().SingleOrDefault(
                        c => ReferenceEquals(c, fi.ReturnTypeAsComplexType.Target));
                    Debug.Assert(
                        complexType != null,
                        string.Format("Complex type {0} for FunctionImport {1} does not exist", complexType.Name, fi.Name));
                    if (complexType != null)
                    {
                        yield return complexType.GetDeleteCommand();
                    }
                }
            }
        }
private static IEnumerable < Command > CreateRemoveFunctionImportCommands ( EntityDesignArtifact designArtifact ) { var model = designArtifact . ConceptualModel ; var cec = ( ConceptualEntityContainer ) model . FirstEntityContainer ; foreach ( var fi in cec . FunctionImports ( ) ) { yield return fi . GetDeleteCommand ( ) ; if ( fi . IsReturnTypeComplexType ) { var complexType = model . ComplexTypes ( ) . SingleOrDefault ( c => ReferenceEquals ( c , fi . ReturnTypeAsComplexType . Target ) ) ; Debug . Assert ( complexType != null , string . Format ( " " , complexType . Name , fi . Name ) ) ; if ( complexType != null ) { yield return complexType . GetDeleteCommand ( ) ; } } } }
Creates commands to remove function imports and complex types corresponding to results if ones exist.
Creates commands to remove function imports and complex types corresponding to results if ones exist .
// we were instructed not to create FunctionImports - but runtime has created them automatically so actually need to delete any which have been created
IEnumerable of commands for deleting function imports and corresponding complex types.
IEnumerable of commands for deleting function imports and corresponding complex types .
designArtifact
EntityDesignArtifact
None
remarks
This function should be called only from RunFinished() method as we don't check whether complex types we
are removing are not used by other function imports or entities.
This function should be called only from RunFinished () method as we don ' t check whether complex types we are removing are not used by other function imports or entities .