Beispiel #1
0
        /// <summary>
        /// Makes a column an Identity column using the specified seed and increment values.
        /// </summary>
        /// <param name="expression">Column on which to apply the identity.</param>
        /// <param name="seed">Starting value of the identity.</param>
        /// <param name="increment">Increment value of the identity.</param>
        /// <returns></returns>
        public static TNext Identity <TNext, TNextFk>(this IColumnOptionSyntax <TNext, TNextFk> expression,
                                                      int seed, int increment) where TNext : IFluentSyntax where TNextFk : IFluentSyntax
        {
            ISupportAdditionalFeatures castColumn = GetColumn(expression);

            castColumn.AddAdditionalFeature(IdentitySeed, seed);
            castColumn.AddAdditionalFeature(IdentityIncrement, increment);
            return(expression.Identity());
        }
Beispiel #2
0
 private static TNext SetIdentity <TNext, TNextFk>(
     IColumnOptionSyntax <TNext, TNextFk> expression,
     object seed,
     int increment,
     ISupportAdditionalFeatures castColumn)
     where TNext : IFluentSyntax where TNextFk : IFluentSyntax
 {
     return(expression.Identity());
 }
        private static TNext SetIdentity <TNext, TNextFk>(IColumnOptionSyntax <TNext, TNextFk> expression, PostgresGenerationType?generation, PostgresIdentityModificationType modificationType, ISupportAdditionalFeatures castColumn)
            where TNext : IFluentSyntax
            where TNextFk : IFluentSyntax
        {
            if (generation.HasValue)
            {
                castColumn.AdditionalFeatures[IdentityGeneration] = generation;
            }

            castColumn.AdditionalFeatures[IdentityModificationType] = modificationType;

            return(expression.Identity());
        }
 private static TNext SetIdentity <TNext, TNextFk>(
     IColumnOptionSyntax <TNext, TNextFk> expression,
     OracleGenerationType generation,
     long?startWith,
     int?incrementBy,
     long?minValue,
     long?maxValue,
     ISupportAdditionalFeatures castColumn)
     where TNext : IFluentSyntax where TNextFk : IFluentSyntax
 {
     castColumn.AdditionalFeatures[IdentityGeneration]  = generation;
     castColumn.AdditionalFeatures[IdentityStartWith]   = startWith;
     castColumn.AdditionalFeatures[IdentityIncrementBy] = incrementBy;
     castColumn.AdditionalFeatures[IdentityMinValue]    = minValue;
     castColumn.AdditionalFeatures[IdentityMaxValue]    = maxValue;
     return(expression.Identity());
 }
        public static void ApplyColumnOptions <TNext, TNextFk>(IColumnOptionSyntax <TNext, TNextFk> builder, ColumnProperty columnProperty, object defaultValue)
            where TNext : IFluentSyntax
            where TNextFk : IFluentSyntax
        {
            if (defaultValue != null)
            {
                builder.WithDefaultValue(defaultValue);
            }

            if (columnProperty.IsSelected(ColumnProperty.Identity))
            {
                builder.Identity();
            }
            if (columnProperty.IsSelected(ColumnProperty.PrimaryKey))
            {
                builder.PrimaryKey();
            }
            if (columnProperty.IsSelected(ColumnProperty.Unsigned))
            {
                // Not supported, but is included in PrimaryKeyWithIdentity, and so it can't throw a NotSupportedException
            }
            if (columnProperty.IsSelected(ColumnProperty.Unique))
            {
                builder.Unique();
            }
            if (columnProperty.IsSelected(ColumnProperty.ForeignKey))
            {
                builder.ForeignKey();
            }

            if (columnProperty.IsSelected(ColumnProperty.NotNull))
            {
                builder.NotNullable();
            }
            else
            {
                builder.Nullable();
            }
        }