EFUtility.CodeGenerationTools.MetadataTools.GetCorrespondingPrincipalProperty C# (CSharp) Method

GetCorrespondingPrincipalProperty() public method

Given a property on the dependent end of a referential constraint, returns the corresponding property on the principal end. Requires: The association has a referential constraint, and the specified dependentProperty is one of the properties on the dependent end.
public GetCorrespondingPrincipalProperty ( System.Data.Metadata.Edm.NavigationProperty navProperty, System.Data.Metadata.Edm.EdmProperty dependentProperty ) : System.Data.Metadata.Edm.EdmProperty
navProperty System.Data.Metadata.Edm.NavigationProperty
dependentProperty System.Data.Metadata.Edm.EdmProperty
return System.Data.Metadata.Edm.EdmProperty
        public EdmProperty GetCorrespondingPrincipalProperty(NavigationProperty navProperty, EdmProperty dependentProperty)
        {
            if (navProperty == null)
            {
                throw new ArgumentNullException("navProperty");
            }

            if (dependentProperty == null)
            {
                throw new ArgumentNullException("dependentProperty");
            }

            ReadOnlyMetadataCollection<EdmProperty> fromProperties = GetPrincipalProperties(navProperty);
            ReadOnlyMetadataCollection<EdmProperty> toProperties = GetDependentProperties(navProperty);
            return fromProperties[toProperties.IndexOf(dependentProperty)];
        }