/// <summary> /// Sets the number of sequence numbers to be preallocated and stored in memory for faster access. /// </summary> /// <param name="property">The property.</param> /// <param name="numbersToCache">The value to set.</param> public static void SetIdentityNumbersToCache([NotNull] this IMutableProperty property, long?numbersToCache) { var options = IdentitySequenceOptionsData.Get(property); options.NumbersToCache = numbersToCache ?? 1; property.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IdentityOptions, options.Serialize()); }
/// <summary> /// Sets whether the identity's sequence is cyclic. /// </summary> /// <param name="property">The property.</param> /// <param name="isCyclic">The value to set.</param> public static void SetIdentityIsCyclic([NotNull] this IMutableProperty property, bool?isCyclic) { var options = IdentitySequenceOptionsData.Get(property); options.IsCyclic = isCyclic ?? false; property.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IdentityOptions, options.Serialize()); }
/// <summary> /// Sets the identity maximum value. /// </summary> /// <param name="property">The property.</param> /// <param name="maxValue">The value to set.</param> public static void SetIdentityMaxValue([NotNull] this IMutableProperty property, long?maxValue) { var options = IdentitySequenceOptionsData.Get(property); options.MaxValue = maxValue; property.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IdentityOptions, options.Serialize()); }
/// <summary> /// Sets the identity increment value. /// </summary> /// <param name="property">The property.</param> /// <param name="incrementBy">The value to set.</param> public static void SetIdentityIncrementBy([NotNull] this IMutableProperty property, long?incrementBy) { var options = IdentitySequenceOptionsData.Get(property); options.IncrementBy = incrementBy ?? 1; property.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IdentityOptions, options.Serialize()); }
/// <summary> /// Sets the number of sequence numbers to be preallocated and stored in memory for faster access. /// </summary> /// <param name="property">The property.</param> /// <param name="numbersToCache">The value to set.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> public static void SetIdentityNumbersToCache( [NotNull] this IConventionProperty property, long?numbersToCache, bool fromDataAnnotation = false) { var options = IdentitySequenceOptionsData.Get(property); options.NumbersToCache = numbersToCache ?? 1; property.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IdentityOptions, options.Serialize(), fromDataAnnotation); }
/// <summary> /// Sets the identity maximum value. /// </summary> /// <param name="property">The property.</param> /// <param name="maxValue">The value to set.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> public static void SetIdentityMaxValue( [NotNull] this IConventionProperty property, long?maxValue, bool fromDataAnnotation = false) { var options = IdentitySequenceOptionsData.Get(property); options.MaxValue = maxValue; property.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IdentityOptions, options.Serialize(), fromDataAnnotation); }
/// <summary> /// Sets the identity increment value. /// </summary> /// <param name="property">The property.</param> /// <param name="incrementBy">The value to set.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> public static void SetIdentityIncrementBy( [NotNull] this IConventionProperty property, long?incrementBy, bool fromDataAnnotation = false) { var options = IdentitySequenceOptionsData.Get(property); options.IncrementBy = incrementBy ?? 1; property.SetOrRemoveAnnotation(NpgsqlAnnotationNames.IdentityOptions, options.Serialize(), fromDataAnnotation); }
/// <summary> /// Returns a value indicating whether the sequence options can be set on the identity column. /// </summary> /// <param name="propertyBuilder">The builder for the property being configured.</param> /// <param name="startValue"> /// The starting value for the sequence. /// The default starting value is <see cref="minValue"/> for ascending sequences and <see cref="maxValue"/> for descending ones. /// </param> /// <param name="incrementBy">The amount to increment between values. Defaults to 1.</param> /// <param name="minValue"> /// The minimum value for the sequence. /// The default for an ascending sequence is 1. The default for a descending sequence is the minimum value of the data type. /// </param> /// <param name="maxValue"> /// The maximum value for the sequence. /// The default for an ascending sequence is the maximum value of the data type. The default for a descending sequence is -1. /// </param> /// <param name="cyclic"> /// Sets whether or not the sequence will start again from the beginning once the maximum value is reached. /// Defaults to false. /// </param> /// <param name="numbersToCache"> /// Specifies how many sequence numbers are to be preallocated and stored in memory for faster access. /// The minimum value is 1 (only one value can be generated at a time, i.e., no cache), and this is also the default. /// </param> /// <returns>The same builder instance so that multiple calls can be chained.</returns> public static bool CanSetIdentityOptions( [NotNull] this IConventionPropertyBuilder propertyBuilder, long?startValue = null, long?incrementBy = null, long?minValue = null, long?maxValue = null, bool?cyclic = null, long?numbersToCache = null) { Check.NotNull(propertyBuilder, nameof(propertyBuilder)); var value = new IdentitySequenceOptionsData { StartValue = startValue, IncrementBy = incrementBy ?? 1, MinValue = minValue, MaxValue = maxValue, IsCyclic = cyclic ?? false, NumbersToCache = numbersToCache ?? 1 }.Serialize(); return(propertyBuilder.CanSetAnnotation(NpgsqlAnnotationNames.IdentityOptions, value)); }
/// <summary> /// Returns the number of sequence numbers to be preallocated and stored in memory for faster access. /// Defaults to 1 (no cache). /// </summary> /// <param name="property">The property.</param> /// <returns>The number of sequence numbers to be cached.</returns> public static long?GetIdentityNumbersToCache([NotNull] this IProperty property) => IdentitySequenceOptionsData.Get(property).NumbersToCache;
/// <summary> /// Returns whether the identity's sequence is cyclic. /// </summary> /// <param name="property">The property.</param> /// <returns>Whether the identity's sequence is cyclic.</returns> public static bool?GetIdentityIsCyclic([NotNull] this IProperty property) => IdentitySequenceOptionsData.Get(property).IsCyclic;
/// <summary> /// Returns the identity maximum value. /// </summary> /// <param name="property">The property.</param> /// <returns>The identity maximum value.</returns> public static long?GetIdentityMaxValue([NotNull] this IProperty property) => IdentitySequenceOptionsData.Get(property).MaxValue;
/// <summary> /// Returns the identity increment value. /// </summary> /// <param name="property">The property.</param> /// <returns>The identity increment value.</returns> public static long?GetIdentityIncrementBy([NotNull] this IProperty property) => IdentitySequenceOptionsData.Get(property).IncrementBy;