src/Shared/EntityFramework/Internal/Validation/EntityValidatorBuilder.cs
// <summary>
// Build validators for the <paramref name="clrProperties" /> and the corresponding <paramref name="edmProperties" />
// or <paramref name="navigationProperties" />.
// </summary>
// <param name="clrProperties"> Properties to build validators for. </param>
// <param name="edmProperties"> Non-navigation EDM properties. </param>
// <param name="navigationProperties"> Navigation EDM properties. </param>
// <returns> A list of validators. Possibly empty, never null. </returns>
Build validators for the  and the corresponding
or .
Build validators for the and the corresponding or .
protected virtual IList<PropertyValidator> BuildValidatorsForProperties(
            IEnumerable<PropertyInfo> clrProperties,
            IEnumerable<EdmProperty> edmProperties,
            IEnumerable<NavigationProperty> navigationProperties)
        {
            DebugCheck.NotNull(edmProperties);
            DebugCheck.NotNull(navigationProperties);
            DebugCheck.NotNull(clrProperties);
            var validators = new List<PropertyValidator>();
            foreach (var property in clrProperties)
            {
                PropertyValidator propertyValidator = null;
                var edmProperty = edmProperties
                    .Where(p => p.Name == property.Name)
                    .SingleOrDefault();
                if (edmProperty != null)
                {
                    var referencingAssociations = from navigationProperty in navigationProperties
                                                  let associationType =
                                                      navigationProperty.RelationshipType as AssociationType
                                                  where associationType != null
                                                  from constraint in associationType.ReferentialConstraints
                                                  where constraint.ToProperties.Contains(edmProperty)
                                                  select constraint;
                    propertyValidator = BuildPropertyValidator(
                        property, edmProperty, buildFacetValidators: !referencingAssociations.Any());
                }
                else
                {
                    propertyValidator = BuildPropertyValidator(property);
                }
                if (propertyValidator != null)
                {
                    validators.Add(propertyValidator);
                }
            }
            return validators;
        }
protected virtual IList < PropertyValidator > BuildValidatorsForProperties ( IEnumerable < PropertyInfo > clrProperties , IEnumerable < EdmProperty > edmProperties , IEnumerable < NavigationProperty > navigationProperties ) { DebugCheck . NotNull ( edmProperties ) ; DebugCheck . NotNull ( navigationProperties ) ; DebugCheck . NotNull ( clrProperties ) ; var validators = new List < PropertyValidator > ( ) ; foreach ( var property in clrProperties ) { PropertyValidator propertyValidator = null ; var edmProperty = edmProperties . Where ( p => p . Name == property . Name ) . SingleOrDefault ( ) ; if ( edmProperty != null ) { var referencingAssociations = from navigationProperty in navigationProperties let associationType = navigationProperty . RelationshipType as AssociationType where associationType != null from constraint in associationType . ReferentialConstraints where constraint . ToProperties . Contains ( edmProperty ) select constraint ; propertyValidator = BuildPropertyValidator ( property , edmProperty , buildFacetValidators : ! referencingAssociations . Any ( ) ) ; } else { propertyValidator = BuildPropertyValidator ( property ) ; } if ( propertyValidator != null ) { validators . Add ( propertyValidator ) ; } } return validators ; }
Build validators for the  and the corresponding
or .
Build validators for the and the corresponding or .
// Currently we don't use facets to build validators for navigation properties, // if this changes in the future we would need to implement and call a different overload // of BuildPropertyValidator here
A list of validators. Possibly empty, never null.
A list of validators . Possibly empty never null .
clrProperties
IEnumerable<PropertyInfo>
Properties to build validators for.
Properties to build validators for .
edmProperties
IEnumerable<EdmProperty>
Non-navigation EDM properties.
Non - navigation EDM properties .
navigationProperties
IEnumerable<NavigationProperty>
Navigation EDM properties.
Navigation EDM properties .