src/Shared/EntityFramework/Core/Query/PlanCompiler/ConstraintManager.cs
// <summary>
// Load all relationships in this entity container
// </summary>
Load all relationships in this entity container
Load all relationships in this entity container
internal void LoadRelationships(md.EntityContainer entityContainer)
        {
            if (m_entityContainerMap.ContainsKey(entityContainer))
            {
                return;
            }
            foreach (var e in entityContainer.BaseEntitySets)
            {
                var relationshipSet = e as md.RelationshipSet;
                if (relationshipSet == null)
                {
                    continue;
                }
                var relationshipType = relationshipSet.ElementType;
                var assocType = relationshipType as md.AssociationType;
                 Handle only binary Association relationships for now
                if (null == assocType
                    || !IsBinary(relationshipType))
                {
                    continue;
                }
                foreach (var constraint in assocType.ReferentialConstraints)
                {
                    List<ForeignKeyConstraint> fkConstraintList;
                    var fkConstraint = new ForeignKeyConstraint(relationshipSet, constraint);
                    if (!m_parentChildRelationships.TryGetValue(fkConstraint.Pair, out fkConstraintList))
                    {
                        fkConstraintList = new List<ForeignKeyConstraint>();
                        m_parentChildRelationships[fkConstraint.Pair] = fkConstraintList;
                    }
                     Theoretically, we can have more than one fk constraint between
                     the 2 tables (though, it is unlikely)
                    fkConstraintList.Add(fkConstraint);
                }
            }
             Mark this entity container as already loaded
            m_entityContainerMap[entityContainer] = entityContainer;
        }
internal void LoadRelationships ( md . EntityContainer entityContainer ) { if ( m_entityContainerMap . ContainsKey ( entityContainer ) ) { return ; } foreach ( var e in entityContainer . BaseEntitySets ) { var relationshipSet = e as md . RelationshipSet ; if ( relationshipSet == null ) { continue ; } var relationshipType = relationshipSet . ElementType ; var assocType = relationshipType as md . AssociationType ; if ( null == assocType || ! IsBinary ( relationshipType ) ) { continue ; } foreach ( var constraint in assocType . ReferentialConstraints ) { List < ForeignKeyConstraint > fkConstraintList ; var fkConstraint = new ForeignKeyConstraint ( relationshipSet , constraint ) ; if ( ! m_parentChildRelationships . TryGetValue ( fkConstraint . Pair , out fkConstraintList ) ) { fkConstraintList = new List < ForeignKeyConstraint > ( ) ; m_parentChildRelationships [ fkConstraint . Pair ] = fkConstraintList ; } fkConstraintList . Add ( fkConstraint ) ; } } m_entityContainerMap [ entityContainer ] = entityContainer ; }
Load all relationships in this entity container
Load all relationships in this entity container
// Check to see if I've already loaded information for this entity container // Load all relationships from this entitycontainer // Relationship sets can only contain relationships // // Handle only binary Association relationships for now // // // Theoretically, we can have more than one fk constraint between // the 2 tables (though, it is unlikely) // // Mark this entity container as already loaded
entityContainer
md.EntityContainer