public static ICreateIndexMethodOptionsSyntax Using(this ICreateIndexOptionsSyntax expression, Algorithm algorithm) { if (expression is ICreateIndexMethodOptionsSyntax) { throw new InvalidOperationException("Only can have one index method."); } var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.Using(algorithm); switch (algorithm) { case Algorithm.BTree: return(new CreateBTreeIndexOptionsSyntax(expression)); case Algorithm.Hash: return(new CreateHashIndexOptionSyntax(expression)); case Algorithm.Gist: return(new CreateGistIndexOptionsSyntax(expression)); case Algorithm.Spgist: return(new CreateSpgistIndexOptionsSyntax(expression)); case Algorithm.Gin: return(new CreateGinIndexOptionsSyntax(expression)); case Algorithm.Brin: return(new CreateBrinIndexOptionsSyntax(expression)); default: throw new ArgumentOutOfRangeException(nameof(algorithm), algorithm, null); } }
public static ICreateIndexOptionsSyntax Using(this ICreateIndexOptionsSyntax expression, Algorithm algorithm) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.Using(algorithm); return(expression); }
/// <summary> /// Indicates not to recurse creating indexes on partitions, if the table is partitioned. /// </summary> /// <param name="expression"></param> /// <param name="isOnly">if should or shouldn't be only</param> /// <returns>The next step</returns> public static ICreateIndexOptionsSyntax AsOnly(this ICreateIndexOptionsSyntax expression, bool isOnly) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.AsOnly(isOnly); return(expression); }
/// <summary> /// Exclusive for BRIN index. Defines whether a summarization run is invoked for the previous page range whenever an insertion is detected on the next one. /// </summary> /// <param name="expression"></param> /// <param name="autosummarize">True to enable fast autosummarize or false to disable.</param> /// <returns>The next step</returns> public static ICreateIndexOptionsSyntax Autosummarize(this ICreateIndexOptionsSyntax expression, bool autosummarize) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.SetAdditionalFeature(IndexAutosummarize, autosummarize); return(expression); }
public static ICreateBrinIndexOptionsSyntax UsingBrin(this ICreateIndexOptionsSyntax expression) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.Using(Algorithm.Brin); return(new CreateBrinIndexOptionsSyntax(expression)); }
/// <summary> /// The tablespace in which to create the index. If not specified, default_tablespace is consulted, or temp_tablespaces for indexes on temporary tables. /// </summary> /// <param name="expression"></param> /// <param name="tablespace">The tablespace</param> /// <returns>The next step</returns> public static ICreateIndexOptionsSyntax Tablespace(this ICreateIndexOptionsSyntax expression, string tablespace) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.SetAdditionalFeature(IndexTablespace, tablespace); return(expression); }
public static ICreateIndexOptionsSyntax UsingSpgist(this ICreateIndexOptionsSyntax expression) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.Using(Algorithm.Spgist); return(expression); }
/// <summary> /// When this option is used, PostgreSQL will build the index without taking any locks that prevent concurrent inserts, updates, or deletes on the table /// Whereas a standard index build locks out writes (but not reads) on the table until it's done. /// There are several caveats to be aware of when using this option /// </summary> /// <param name="expression"></param> /// <returns>The next step</returns> /// <remarks> /// To use this feature is necessary mark the migration to not use transaction. /// sample: /// [Migration(1, TransactionBehavior.None)] /// public class SomeMigration : Migration /// </remarks> public static ICreateIndexOptionsSyntax AsConcurrently(this ICreateIndexOptionsSyntax expression) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.AsConcurrently(true); return(expression); }
/// <summary> /// The constraint expression for a partial index. /// </summary> /// <param name="expression"></param> /// <param name="filter">The constraint expression</param> /// <returns>The next step</returns> public static ICreateIndexOptionsSyntax Filter(this ICreateIndexOptionsSyntax expression, string filter) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.SetAdditionalFeature(IndexFilter, filter); return(expression); }
public static ICreateIndexOptionsSyntax WithDataCompression(this ICreateIndexOptionsSyntax expression, DataCompressionType dataCompressionType) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.SetAdditionalFeature(DataCompression, dataCompressionType); return(expression); }
public static ICreateIndexOptionsSyntax Include(this ICreateIndexOptionsSyntax expression, string columnName) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.Include(columnName); return(expression); }
/// <summary> /// Exclusive for BRIN index. Defines the number of table blocks that make up one block range for each entry of a BRIN index. /// For more information about it see: https://www.postgresql.org/docs/current/brin-intro.html /// </summary> /// <param name="expression"></param> /// <param name="range">The page per range</param> /// <returns>The next step</returns> public static ICreateIndexOptionsSyntax PagesPerRange(this ICreateIndexOptionsSyntax expression, int range) { var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.SetAdditionalFeature(IndexPagesPerRange, range); return(expression); }
/// <summary> /// Specifies whether underlying tables and associated indexes are available for queries and data modification during the index operation. /// The ONLINE option can only be specified in certain situations, please refer to documentation for SQL Server 2005 and newer. /// </summary> /// <param name="expression">The expression to use to set the <c>WITH(ONLINE=)</c> option</param> /// <param name="active"> /// <c>true</c> /// Long-term table locks are not held. This allows queries or updates to the underlying table to continue. /// <c>false</c> /// Table locks are applied and the table is unavailable for the duration of the index operation. /// </param> public static ICreateIndexOptionsSyntax Online(this ICreateIndexOptionsSyntax expression, bool active = true) { var additionalFeatures = expression as ISupportAdditionalFeatures ?? throw new InvalidOperationException(UnsupportedMethodMessage(nameof(Online), nameof(ISupportAdditionalFeatures))); additionalFeatures.AdditionalFeatures[OnlineIndex] = active; return(expression); }
/// <summary> /// Index should have unique values. Only one row with null value should be accepted (default for most known database engines). /// </summary> /// <param name="expression">The expression to set this option for</param> /// <param name="nullsAreDistinct"><c>true</c> when nulls should be distinct</param> /// <returns>The <paramref name="expression"/></returns> public static ICreateIndexOnColumnSyntax UniqueNullsDistinct(this ICreateIndexOptionsSyntax expression, bool nullsAreDistinct = true) { var additionalFeatures = expression as ISupportAdditionalFeatures ?? throw new InvalidOperationException(UnsupportedMethodMessage("Nulls(Not)Distinct", nameof(ISupportAdditionalFeatures))); additionalFeatures.AdditionalFeatures[IndexColumnNullsDistinct] = nullsAreDistinct; return(expression.Unique()); }
public static ICreateGinIndexOptionsSyntax UsingGin(this ICreateIndexOptionsSyntax expression) { if (expression is ICreateIndexMethodOptionsSyntax) { throw new InvalidOperationException("Only can have one index method."); } var additionalFeatures = expression as ISupportAdditionalFeatures; additionalFeatures.Using(Algorithm.Gin); return(new CreateGinIndexOptionsSyntax(expression)); }
public static ICreateIndexOptionsSyntax Include(this ICreateIndexOptionsSyntax expression, string columnName) { CreateIndexExpressionBuilder castIndex = expression as CreateIndexExpressionBuilder; if (castIndex == null) { throw new InvalidOperationException("The Include method can only be called on a valid object."); } castIndex.Expression.Index.Includes.Add(new IndexIncludeDefinition { Name = columnName });; return(expression); }
/// <inheritdoc /> public CreateGistIndexOptionsSyntax([NotNull] ICreateIndexOptionsSyntax createIndexOptionsSyntax) : base(createIndexOptionsSyntax) { }
/// <inheritdoc /> public CreateHashIndexOptionSyntax([NotNull] ICreateIndexOptionsSyntax createIndexOptionsSyntax) : base(createIndexOptionsSyntax) { }
/// <summary> /// Index should have unique values, but multiple rows with null values should be accepted. /// </summary> /// <param name="expression">The expression to set this option for</param> /// <returns>The <paramref name="expression"/></returns> public static ICreateIndexOnColumnSyntax UniqueNullsNotDistinct( this ICreateIndexOptionsSyntax expression) { return(UniqueNullsDistinct(expression, false)); }
protected AbstractCreateIndexMethodOptionsSyntax([NotNull] ICreateIndexOptionsSyntax createIndexOptionsSyntax) { CreateIndexOptionsSyntax = createIndexOptionsSyntax ?? throw new ArgumentNullException(nameof(createIndexOptionsSyntax)); }
/// <summary> /// The fillfactor for an index is a percentage that determines how full the index method will try to pack index pages. /// </summary> /// <param name="expression"></param> /// <param name="fillfactor">The fillfactor value from 10 to 100 can be selected</param> /// <returns>The next step</returns> /// <remarks> /// For B-trees, leaf pages are filled to this percentage during initial index build, and also when extending /// the index at the right (adding new largest key values). If pages subsequently become completely full, /// they will be split, leading to gradual degradation in the index's efficiency. /// B-trees use a default fillfactor of 90, but any integer value from 10 to 100 can be selected. /// If the table is static then fillfactor 100 is best to minimize the index's physical size, /// but for heavily updated tables a smaller fillfactor is better to minimize the need for page splits. /// The other index methods use fillfactor in different but roughly analogous ways; the default fillfactor varies between methods. /// </remarks> public static ICreateBTreeIndexOptionsSyntax Fillfactor(this ICreateIndexOptionsSyntax expression, int fillfactor) { return(expression.UsingBTree() .Fillfactor(fillfactor) as ICreateBTreeIndexOptionsSyntax); }