src/Misc/EFTools/EntityDesignDatabaseGeneration/MetadataWorkspaceExtensions.cs
/// <summary>
///     Retrieves the dependent end of this association, given the following rules in order of priority:
///     1. If there is a referential constraint defined on the association, this returns the DependentEnd.
///     2. If the association's multiplicity is 1:1 and OnDelete='Cascade' is defined on the first end, then this returns the second end.
///     If OnDelete='Cascade' is not defined on the first end, this returns the first end.
///     3. In a 1:* or 0..1:* association, this returns the end with the * multiplicity.
///     4. In a 0..1:1 association, this returns the end with the 0..1 multiplicity.
/// </summary>
/// <param name="association">The association.</param>
/// <returns>The dependent end.</returns>
/// <exception cref="InvalidOperationException">if this association is *:*</exception>
Retrieves the dependent end of this association, given the following rules in order of priority:
1. If there is a referential constraint defined on the association, this returns the DependentEnd.
2. If the association's multiplicity is 1:1 and OnDelete='Cascade' is defined on the first end, then this returns the second end.
If OnDelete='Cascade' is not defined on the first end, this returns the first end.
3. In a 1:* or 0..1:* association, this returns the end with the * multiplicity.
4. In a 0..1:1 association, this returns the end with the 0..1 multiplicity.
Retrieves the dependent end of this association given the following rules in order of priority : 1 . If there is a referential constraint defined on the association this returns the DependentEnd . 2 . If the association ' s multiplicity is 1 : 1 and OnDelete = ' Cascade ' is defined on the first end then this returns the second end . If OnDelete = ' Cascade ' is not defined on the first end this returns the first end . 3 . In a 1 : * or 0 .. 1 : * association this returns the end with the * multiplicity . 4 . In a 0 .. 1 : 1 association this returns the end with the 0 .. 1 multiplicity .
public static AssociationEndMember GetDependentEnd(this AssociationType association)
        {
            Debug.Assert(false == association.IsManyToMany(), Resources.ErrorGetDependentEndOnManyToMany);
            if (association.IsManyToMany())
            {
                throw new InvalidOperationException(Resources.ErrorGetDependentEndOnManyToMany);
            }
            if (association.ReferentialConstraints.Count > 0)
            {
                return association.ReferentialConstraints.FirstOrDefault().ToRole as AssociationEndMember;
            }
            else
            {
                if (association.GetEnd1().RelationshipMultiplicity == RelationshipMultiplicity.One
                    && association.GetEnd2().RelationshipMultiplicity == RelationshipMultiplicity.One)
                {
                    return association.GetEnd1().GetOnDelete() == OperationAction.Cascade ? association.GetEnd2() : association.GetEnd1();
                }
                if ((association.GetEnd1().RelationshipMultiplicity == RelationshipMultiplicity.Many)
                    ||
                    (association.GetEnd1().RelationshipMultiplicity == RelationshipMultiplicity.ZeroOrOne
                     && association.GetEnd2().RelationshipMultiplicity == RelationshipMultiplicity.One))
                {
                    return association.GetEnd1();
                }
                return association.GetEnd2();
            }
        }
public static AssociationEndMember GetDependentEnd ( this AssociationType association ) { Debug . Assert ( false == association . IsManyToMany ( ) , Resources . ErrorGetDependentEndOnManyToMany ) ; if ( association . IsManyToMany ( ) ) { throw new InvalidOperationException ( Resources . ErrorGetDependentEndOnManyToMany ) ; } if ( association . ReferentialConstraints . Count > 0 ) { return association . ReferentialConstraints . FirstOrDefault ( ) . ToRole as AssociationEndMember ; } else { if ( association . GetEnd1 ( ) . RelationshipMultiplicity == RelationshipMultiplicity . One && association . GetEnd2 ( ) . RelationshipMultiplicity == RelationshipMultiplicity . One ) { return association . GetEnd1 ( ) . GetOnDelete ( ) == OperationAction . Cascade ? association . GetEnd2 ( ) : association . GetEnd1 ( ) ; } if ( ( association . GetEnd1 ( ) . RelationshipMultiplicity == RelationshipMultiplicity . Many ) || ( association . GetEnd1 ( ) . RelationshipMultiplicity == RelationshipMultiplicity . ZeroOrOne && association . GetEnd2 ( ) . RelationshipMultiplicity == RelationshipMultiplicity . One ) ) { return association . GetEnd1 ( ) ; } return association . GetEnd2 ( ) ; } }
Retrieves the dependent end of this association, given the following rules in order of priority:
1.
Retrieves the dependent end of this association given the following rules in order of priority : 1 .
// Dependency is implied by OnDelete in 1:1 associations // Dependency can also be implied by the multiplicity of the association
The dependent end.
The dependent end .
if this association is *.
if this association is * .
AssociationType
this
association
None