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);
        }
Example #2
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 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 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 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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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);
        }
Example #12
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);
        }
 /// <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);
Example #15
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 #16
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 #17
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 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);
 /// <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);
 /// <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 void SetMethod([NotNull] this IConventionIndex index, [CanBeNull] string method, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexMethod, method, fromDataAnnotation);
 /// <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 void SetIsCreatedConcurrently(
     [NotNull] this IConventionIndex index, bool?createdConcurrently, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.CreatedConcurrently, createdConcurrently, fromDataAnnotation);
 /// <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 void SetIncludeProperties(
     [NotNull] this IConventionIndex index, [NotNull] IReadOnlyList <string> properties, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(
     NpgsqlAnnotationNames.IndexInclude,
     properties,
     fromDataAnnotation);
 /// <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 void SetNullSortOrder([NotNull] this IConventionIndex index,
                                     [CanBeNull] IReadOnlyList <NullSortOrder> nullSortOrder, bool fromDataAnnotation)
 => index.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IndexNullSortOrder, nullSortOrder, fromDataAnnotation);
 /// <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>
 public static void SetSqlServerIsClustered(
     [NotNull] this IConventionIndex index, bool?value, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(
     SqlServerAnnotationNames.Clustered,
     value,
     fromDataAnnotation);
 /// <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>
 public static void SetSqlServerIsCreatedOnline(
     [NotNull] this IConventionIndex index, bool?createdOnline, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(
     SqlServerAnnotationNames.CreatedOnline,
     createdOnline,
     fromDataAnnotation);
Example #26
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>
 public static void SetFilter([NotNull] this IConventionIndex index, [CanBeNull] string value, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(
     RelationalAnnotationNames.Filter,
     Check.NullButNotEmpty(value, nameof(value)),
     fromDataAnnotation);
 /// <summary>
 ///     Sets a value indicating whether the index is spartial.
 /// </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 SetIsSpatial(
     [NotNull] this IConventionIndex index, bool?value, bool fromDataAnnotation = false)
 => index.SetOrRemoveAnnotation(
     MySqlAnnotationNames.SpatialIndex,
     value,
     fromDataAnnotation);