src/Misc/EFTools/EntityDesignModel/ModelHelper.cs
/// <summary>
///     Return the list of entity-types that are related (through association or direct inheritance) to the passed in entity-type.
///     TODO: there are common functionality between this method and EntiyTypeShape's CreateEntityTypeShapeAndConnectorsInDiagram,
///     We should be able to extract common functionality that can be shared between 2 methods.
/// </summary>
Return the list of entity-types that are related (through association or direct inheritance) to the passed in entity-type.
TODO: there are common functionality between this method and EntiyTypeShape's CreateEntityTypeShapeAndConnectorsInDiagram,
We should be able to extract common functionality that can be shared between 2 methods.
Return the list of entity - types that are related ( through association or direct inheritance ) to the passed in entity - type . TODO : there are common functionality between this method and EntiyTypeShape ' s CreateEntityTypeShapeAndConnectorsInDiagram We should be able to extract common functionality that can be shared between 2 methods .
internal static IEnumerable<EntityType> GetRelatedEntityTypes(EntityType entityType)
        {
            var relatedEntityTypes = new HashSet<EntityType>();
            ICollection<Association> participatingAssociations = Association.GetAssociationsForEntityType(entityType);
            Debug.Assert(participatingAssociations != null, "Association's GetAssociationsForEntityType returns null.");
            if (participatingAssociations != null)
            {
                foreach (var association in participatingAssociations)
                {
                    foreach (var et in association.AssociationEnds().Select(ae => ae.Type.SafeTarget).ToList())
                    {
                        if (relatedEntityTypes.Contains(et) == false
                            && et != entityType)
                        {
                            relatedEntityTypes.Add(et);
                        }
                    }
                }
            }
            var cet = entityType as ConceptualEntityType;
            if (cet != null)
            {
                if (cet.SafeBaseType != null
                    && relatedEntityTypes.Contains(cet.SafeBaseType) == false)
                {
                    relatedEntityTypes.Add(cet.SafeBaseType);
                }
                foreach (var derivedEntityType in cet.ResolvableDirectDerivedTypes)
                {
                    if (relatedEntityTypes.Contains(derivedEntityType) == false)
                    {
                        relatedEntityTypes.Add(derivedEntityType);
                    }
                }
            }
            return relatedEntityTypes;
        }
internal static IEnumerable < EntityType > GetRelatedEntityTypes ( EntityType entityType ) { var relatedEntityTypes = new HashSet < EntityType > ( ) ; ICollection < Association > participatingAssociations = Association . GetAssociationsForEntityType ( entityType ) ; Debug . Assert ( participatingAssociations != null , " " ) ; if ( participatingAssociations != null ) { foreach ( var association in participatingAssociations ) { foreach ( var et in association . AssociationEnds ( ) . Select ( ae => ae . Type . SafeTarget ) . ToList ( ) ) { if ( relatedEntityTypes . Contains ( et ) == false && et != entityType ) { relatedEntityTypes . Add ( et ) ; } } } } var cet = entityType as ConceptualEntityType ; if ( cet != null ) { if ( cet . SafeBaseType != null && relatedEntityTypes . Contains ( cet . SafeBaseType ) == false ) { relatedEntityTypes . Add ( cet . SafeBaseType ) ; } foreach ( var derivedEntityType in cet . ResolvableDirectDerivedTypes ) { if ( relatedEntityTypes . Contains ( derivedEntityType ) == false ) { relatedEntityTypes . Add ( derivedEntityType ) ; } } } return relatedEntityTypes ; }
Return the list of entity-types that are related (through association or direct inheritance) to the passed in entity-type.
Return the list of entity - types that are related ( through association or direct inheritance ) to the passed in entity - type .
// Add related entity-types (through) association to the list. // check if the entity-type is not already in the list and is not equal to the passed in entity-type (Self association scenario). // Check if the entity-type is a conceptual entity-type, if yes we need to examine the inheritance relationship too. // check the immediate base type. // check the derived types
entityType
EntityType