Example #1
0
        /// <summary>
        /// Sets a value indicating whether the index is created concurrently.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="createdConcurrently">The value to set.</param>
        /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
        public static bool?SetIsCreatedConcurrently(
            this IConventionIndex index, bool?createdConcurrently, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.CreatedConcurrently, createdConcurrently, fromDataAnnotation);

            return(createdConcurrently);
        }
 public override IConventionIndex OnIndexRemoved(
     IConventionEntityTypeBuilder entityTypeBuilder,
     IConventionIndex index)
 {
     Add(new OnIndexRemovedNode(entityTypeBuilder, index));
     return(index);
 }
Example #3
0
        /// <summary>
        ///     Sets the index filter expression.
        /// </summary>
        /// <param name="index"> The index. </param>
        /// <param name="value"> The value to set. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> The configured value. </returns>
        public static string SetFilter([NotNull] this IConventionIndex index, [CanBeNull] string value, bool fromDataAnnotation = false)
        {
            index.SetAnnotation(
                RelationalAnnotationNames.Filter,
                Check.NullButNotEmpty(value, nameof(value)),
                fromDataAnnotation);

            return(value);
        }
Example #4
0
        /// <summary>
        ///     Sets the name of the index in the database.
        /// </summary>
        /// <param name="index"> The index. </param>
        /// <param name="name"> The value to set. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> The configured value. </returns>
        public static string SetDatabaseName([NotNull] this IConventionIndex index, [CanBeNull] string name, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(
                RelationalAnnotationNames.Name,
                Check.NullButNotEmpty(name, nameof(name)),
                fromDataAnnotation);

            return(name);
        }
        /// <summary>
        ///     Sets a value indicating whether the index is clustered.
        /// </summary>
        /// <param name="value"> The value to set. </param>
        /// <param name="index"> The index. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> The configured value. </returns>
        public static bool?SetIsClustered(
            [NotNull] this IConventionIndex index, bool?value, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(
                SqlServerAnnotationNames.Clustered,
                value,
                fromDataAnnotation);

            return(value);
        }
        /// <summary>
        ///     Sets a value indicating whether the index is online.
        /// </summary>
        /// <param name="index"> The index. </param>
        /// <param name="createdOnline"> The value to set. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> The configured value. </returns>
        public static bool?SetIsCreatedOnline(
            [NotNull] this IConventionIndex index, bool?createdOnline, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(
                SqlServerAnnotationNames.CreatedOnline,
                createdOnline,
                fromDataAnnotation);

            return(createdOnline);
        }
        /// <summary>
        ///     Sets included property names.
        /// </summary>
        /// <param name="index"> The index. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <param name="properties"> The value to set. </param>
        /// <returns> The configured property names. </returns>
        public static IReadOnlyList <string> SetIncludeProperties(
            [NotNull] this IConventionIndex index, [NotNull] IReadOnlyList <string> properties, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(
                SqlServerAnnotationNames.Include,
                properties,
                fromDataAnnotation);

            return(properties);
        }
Example #8
0
        /// <summary>
        /// Sets the column collations to be used, or <c>null</c> if they have not been specified.
        /// </summary>
        /// <remarks>
        /// https://www.postgresql.org/docs/current/static/indexes-collations.html
        /// </remarks>
        public static IReadOnlyList <string>?SetCollation(
            this IConventionIndex index,
            IReadOnlyList <string>?collations,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(collations, nameof(collations));

            index.SetOrRemoveAnnotation(RelationalAnnotationNames.Collation, collations, fromDataAnnotation);

            return(collations);
        }
Example #9
0
        /// <summary>
        /// Sets the column operators to be used, or <c>null</c> if they have not been specified.
        /// </summary>
        /// <remarks>
        /// https://www.postgresql.org/docs/current/static/indexes-opclass.html
        /// </remarks>
        public static IReadOnlyList <string>?SetOperators(
            this IConventionIndex index,
            IReadOnlyList <string>?operators,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(operators, nameof(operators));

            index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexOperators, operators, fromDataAnnotation);

            return(operators);
        }
Example #10
0
        /// <summary>
        /// Sets the index method to be used, or <c>null</c> if it hasn't been specified.
        /// <c>null</c> selects the default (currently <c>btree</c>).
        /// </summary>
        /// <remarks>
        /// http://www.postgresql.org/docs/current/static/sql-createindex.html
        /// </remarks>
        public static string?SetMethod(
            this IConventionIndex index,
            string?method,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(method, nameof(method));

            index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexMethod, method, fromDataAnnotation);

            return(method);
        }
Example #11
0
        /// <summary>
        /// Sets the index to tsvector config name to be used.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="config">
        /// <para>
        /// The text search configuration for this generated tsvector property, or <c>null</c> if this is not a
        /// generated tsvector property.
        /// </para>
        /// <para>
        /// See https://www.postgresql.org/docs/current/textsearch-controls.html for more information.
        /// </para>
        /// </param>
        /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
        /// <remarks>
        /// https://www.postgresql.org/docs/current/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX
        /// </remarks>
        public static string?SetTsVectorConfig(
            this IConventionIndex index,
            string?config,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(config, nameof(config));

            index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.TsVectorConfig, config, fromDataAnnotation);

            return(config);
        }
Example #12
0
        /// <summary>
        /// Sets the column NULL sort orders to be used, or <c>null</c> if they have not been specified.
        /// </summary>
        /// <remarks>
        /// https://www.postgresql.org/docs/current/static/indexes-ordering.html
        /// </remarks>
        public static IReadOnlyList <NullSortOrder>?SetNullSortOrder(
            this IConventionIndex index,
            IReadOnlyList <NullSortOrder>?nullSortOrder,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(nullSortOrder, nameof(nullSortOrder));

            index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexNullSortOrder, nullSortOrder, fromDataAnnotation);

            return(nullSortOrder);
        }
Example #13
0
        /// <summary>
        /// Sets the column sort orders to be used, or <c>null</c> if they have not been specified.
        /// </summary>
        /// <remarks>
        /// https://www.postgresql.org/docs/current/static/indexes-ordering.html
        /// </remarks>
        public static IReadOnlyList <SortOrder> SetSortOrder(
            [NotNull] this IConventionIndex index,
            [CanBeNull] IReadOnlyList <SortOrder> sortOrder,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(sortOrder, nameof(sortOrder));

            index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexSortOrder, sortOrder, fromDataAnnotation);

            return(sortOrder);
        }
 /// <summary>
 ///     Called after an index is removed.
 /// </summary>
 /// <param name="entityTypeBuilder"> The builder for the entity type. </param>
 /// <param name="index"> The removed index. </param>
 /// <param name="context"> Additional information associated with convention execution. </param>
 public virtual void ProcessIndexRemoved(
     IConventionEntityTypeBuilder entityTypeBuilder,
     IConventionIndex index,
     IConventionContext <IConventionIndex> context)
 {
     foreach (var foreignKey in index.DeclaringEntityType.GetDerivedTypesInclusive()
              .SelectMany(t => t.GetDeclaredForeignKeys())
              .Where(fk => AreIndexedBy(fk.Properties, fk.IsUnique, index.Properties, index.IsUnique)))
     {
         CreateIndex(foreignKey.Properties, foreignKey.IsUnique, foreignKey.DeclaringEntityType.Builder);
     }
 }
Example #15
0
        /// <summary>
        /// Sets included property names.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
        /// <param name="properties">The value to set.</param>
        public static IReadOnlyList <string>?SetIncludeProperties(
            this IConventionIndex index,
            IReadOnlyList <string>?properties,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(properties, nameof(properties));

            index.SetOrRemoveAnnotation(
                NpgsqlAnnotationNames.IndexInclude,
                properties,
                fromDataAnnotation);

            return(properties);
        }
        /// <summary>
        ///     Defines a value indicating whether the index uses the fill factor.
        /// </summary>
        /// <param name="index"> The index. </param>
        /// <param name="fillFactor"> The value to set. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> The configured value. </returns>
        public static int?SetFillFactor(
            [NotNull] this IConventionIndex index,
            int?fillFactor,
            bool fromDataAnnotation = false)
        {
            if (fillFactor != null && (fillFactor <= 0 || fillFactor > 100))
            {
                throw new ArgumentOutOfRangeException(nameof(fillFactor));
            }

            index.SetOrRemoveAnnotation(
                SqlServerAnnotationNames.FillFactor,
                fillFactor,
                fromDataAnnotation);

            return(fillFactor);
        }
Example #17
0
 public abstract IConventionIndex OnIndexRemoved(
     [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionIndex index);
 public OnIndexRemovedNode(IConventionEntityTypeBuilder entityTypeBuilder, IConventionIndex index)
 {
     EntityTypeBuilder = entityTypeBuilder;
     Index             = index;
 }
 private static void RemoveIndex(IConventionIndex index)
 => index.DeclaringEntityType.Builder.HasNoIndex(index);
Example #20
0
        /// <summary>
        ///     Sets a value indicating which full text parser to used.
        /// </summary>
        /// <param name="value"> The value to set. </param>
        /// <param name="index"> The index. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        public static string SetFullTextParser([NotNull] this IConventionIndex index, [CanBeNull] string value, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(MySqlAnnotationNames.FullTextParser, value, fromDataAnnotation);

            return(value);
        }
Example #21
0
 /// <summary>
 ///     Returns the <see cref="ConfigurationSource" /> for whether the index is full text.
 /// </summary>
 /// <param name="property"> The property. </param>
 /// <returns> The <see cref="ConfigurationSource" /> for whether the index is full text. </returns>
 public static ConfigurationSource?GetFullTextParserConfigurationSource([NotNull] this IConventionIndex property)
 => property.FindAnnotation(MySqlAnnotationNames.FullTextParser)?.GetConfigurationSource();
Example #22
0
        /// <summary>
        ///     Sets a value indicating whether the index is full text.
        /// </summary>
        /// <param name="value"> The value to set. </param>
        /// <param name="index"> The index. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        public static bool?SetIsFullText([NotNull] this IConventionIndex index, bool?value, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(MySqlAnnotationNames.FullTextIndex, value, fromDataAnnotation);

            return(value);
        }
Example #23
0
 /// <summary>
 ///     Returns the <see cref="ConfigurationSource" /> for whether the index is spartial.
 /// </summary>
 /// <param name="property"> The property. </param>
 /// <returns> The <see cref="ConfigurationSource" /> for whether the index is spartial. </returns>
 public static ConfigurationSource?GetIsSpatialConfigurationSource([NotNull] this IConventionIndex property)
 => property.FindAnnotation(MySqlAnnotationNames.SpatialIndex)?.GetConfigurationSource();
Example #24
0
 /// <summary>
 ///     Returns the <see cref="ConfigurationSource" /> for prefix lengths of the index.
 /// </summary>
 /// <param name="property"> The property. </param>
 /// <returns> The <see cref="ConfigurationSource" /> for prefix lengths of the index. </returns>
 public static ConfigurationSource?GetPrefixLengthConfigurationSource([NotNull] this IConventionIndex property)
 => property.FindAnnotation(MySqlAnnotationNames.IndexPrefixLength)?.GetConfigurationSource();
Example #25
0
        /// <summary>
        ///     Sets prefix lengths for the index.
        /// </summary>
        /// <param name="values"> The prefix lengths to set.
        /// A value of `0` indicates, that the full length should be used for that column. </param>
        /// <param name="index"> The index. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        public static int[] SetPrefixLength([NotNull] this IConventionIndex index, int[] values, bool fromDataAnnotation = false)
        {
            index.SetOrRemoveAnnotation(MySqlAnnotationNames.IndexPrefixLength, values, fromDataAnnotation);

            return(values);
        }
 /// <summary>
 ///     Sets a value indicating whether the index is full text.
 /// </summary>
 /// <param name="value"> The value to set. </param>
 /// <param name="index"> The index. </param>
 /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
 public static void SetIsFullText(
     [NotNull] this IConventionIndex index, bool?value, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(
     MySQLAnnotationNames.FullTextIndex,
     value,
     fromDataAnnotation);
 /// <summary>
 ///     Returns the <see cref="ConfigurationSource" /> for whether the index is full text.
 /// </summary>
 /// <param name="property"> The property. </param>
 /// <returns> The <see cref="ConfigurationSource" /> for whether the index is full text. </returns>
 public static ConfigurationSource?GetIsFullTextConfigurationSource([NotNull] this IConventionIndex property)
 => property.FindAnnotation(MySQLAnnotationNames.FullTextIndex)?.GetConfigurationSource();
 /// <summary>
 /// Sets the column operators to be used, or <c>null</c> if they have not been specified.
 /// </summary>
 /// <remarks>
 /// https://www.postgresql.org/docs/current/static/indexes-opclass.html
 /// </remarks>
 public static void SetOperators([NotNull] this IConventionIndex index, [CanBeNull] IReadOnlyList <string> operators, bool fromDataAnnotation)
 => index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexOperators, operators, fromDataAnnotation);
Example #29
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual IConventionIndex OnIndexRemoved(
     [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionIndex index)
 => _scope.OnIndexRemoved(entityTypeBuilder, index);
 /// <summary>
 /// Sets the column collations to be used, or <c>null</c> if they have not been specified.
 /// </summary>
 /// <remarks>
 /// https://www.postgresql.org/docs/current/static/indexes-collations.html
 /// </remarks>
 public static void SetCollation([NotNull] this IConventionIndex index, [CanBeNull] IReadOnlyList <string> collations, bool fromDataAnnotation)
 => index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexCollation, collations, fromDataAnnotation);