Example #1
0
        /// <summary>
        ///     Gets the foreign keys defined on the given properties. Only foreign keys that are defined on exactly the specified
        ///     set of properties are returned.
        /// </summary>
        /// <param name="entityType"> The entity type to find the foreign keys on. </param>
        /// <param name="properties"> The properties to find the foreign keys on. </param>
        /// <returns> The foreign keys. </returns>
        public static IEnumerable <IForeignKey> FindForeignKeys(
            [NotNull] this IEntityType entityType, [NotNull] IReadOnlyList <IProperty> properties)
        {
            Check.NotNull(entityType, nameof(entityType));
            Check.NotEmpty(properties, nameof(properties));
            Check.HasNoNulls(properties, nameof(properties));

            return(entityType.GetForeignKeys()
                   .Where(foreignKey => PropertyListComparer.Instance.Equals(foreignKey.Properties, properties)));
        }
        /// <summary>
        ///     Gets the foreign keys defined on the given properties. Only foreign keys that are defined on exactly the specified
        ///     set of properties are returned.
        /// </summary>
        /// <param name="entityType"> The entity type to find the foreign keys on. </param>
        /// <param name="properties"> The properties to find the foreign keys on. </param>
        /// <returns> The foreign keys. </returns>
        public static IEnumerable <IForeignKey> FindForeignKeys(
            [NotNull] this IEntityType entityType, [NotNull] IReadOnlyList <IProperty> properties)
        {
            Check.NotNull(entityType, nameof(entityType));
            Check.NotEmpty(properties, nameof(properties));
            Check.HasNoNulls(properties, nameof(properties));

            foreach (var foreignKey in entityType.GetForeignKeys())
            {
                if (PropertyListComparer.Instance.Equals(foreignKey.Properties, properties))
                {
                    yield return(foreignKey);
                }
            }
        }