Esempio n. 1
0
        public static EndProperty GetParentChildRelationEndProperty(this Edmx edmx, string parentEntityName, string childPropertyName)
        {
            NavigationProperty navigationProperty = edmx.GetNavigationProperty(parentEntityName, childPropertyName);
            string             relationship       = GetAdjustedText(navigationProperty.Relationship);

            string fromRole = navigationProperty.FromRole;
            string toRole   = navigationProperty.ToRole;

            LinqToEdmx.Model.Conceptual.Association association = edmx.GetConceptualAssociation(relationship);

            LinqToEdmx.Model.Conceptual.AssociationEnd fromAssociation = edmx.GetConceptualAssociationEnd(relationship, fromRole);
            LinqToEdmx.Model.Conceptual.AssociationEnd toAssociation   = edmx.GetConceptualAssociationEnd(relationship, toRole);

            string childEntityName = GetAdjustedText(toAssociation.Type);
            AssociationSetMapping entityTypesMappingAssociation = edmx.GetMappingAssociationSet(childEntityName, relationship);

            return(entityTypesMappingAssociation.EndProperties.Where(e => e.Name == fromRole).Single());
        }