Example #1
0
        /// <summary>
        ///     Gets the index defined on the given property or creates a new one if one is not already defined.
        /// </summary>
        /// <param name="entityType"> The entity type to get or add the index to. </param>
        /// <param name="properties"> The properties to be indexed. </param>
        /// <returns> The existing or newly created index. </returns>
        public static IMutableIndex GetOrAddIndex(
            [NotNull] this IMutableEntityType entityType, [NotNull] IReadOnlyList <IMutableProperty> properties)
        {
            Check.NotNull(entityType, nameof(entityType));

            return(entityType.FindIndex(properties) ?? entityType.AddIndex(properties));
        }
Example #2
0
        /// <summary>
        ///     Gets the index defined on the given property. Returns null if no index is defined.
        /// </summary>
        /// <param name="entityType"> The entity type to find the index on. </param>
        /// <param name="property"> The property to find the index on. </param>
        /// <returns> The index, or null if none is found. </returns>
        public static IMutableIndex FindIndex([NotNull] this IMutableEntityType entityType, [NotNull] IProperty property)
        {
            Check.NotNull(entityType, nameof(entityType));

            return(entityType.FindIndex(new[] { property }));
        }
 public static IMutableIndex?FindIndex([NotNull] this IMutableEntityType entityType, [NotNull] IReadOnlyProperty property)
 => entityType.FindIndex(new[] { property });