Ejemplo n.º 1
0
        public static bool AreCompatible(
            [NotNull] EntityType principalEntityType,
            [NotNull] EntityType dependentEntityType,
            [CanBeNull] string navigationToPrincipalName,
            [CanBeNull] string navigationToDependentName,
            [CanBeNull] IReadOnlyList <Property> dependentProperties,
            [CanBeNull] IReadOnlyList <Property> principalProperties,
            bool?unique,
            bool?required,
            bool shouldThrow)
        {
            Check.NotNull(principalEntityType, nameof(principalEntityType));
            Check.NotNull(dependentEntityType, nameof(dependentEntityType));

            if (!string.IsNullOrEmpty(navigationToDependentName) &&
                !Navigation.IsCompatible(
                    navigationToDependentName,
                    principalEntityType,
                    dependentEntityType,
                    !unique,
                    shouldThrow))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(navigationToPrincipalName) &&
                !Navigation.IsCompatible(
                    navigationToPrincipalName,
                    dependentEntityType,
                    principalEntityType,
                    false,
                    shouldThrow))
            {
                return(false);
            }

            if ((dependentProperties != null) &&
                !CanPropertiesBeRequired(dependentProperties, required, dependentEntityType, true))
            {
                return(false);
            }

            if ((principalProperties != null) &&
                (dependentProperties != null) &&
                !AreCompatible(
                    principalProperties,
                    dependentProperties,
                    principalEntityType,
                    dependentEntityType,
                    shouldThrow))
            {
                return(false);
            }

            return(true);
        }