Ejemplo n.º 1
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual ValueGenerator Create(
            IProperty property,
            NpgsqlSequenceValueGeneratorState generatorState,
            INpgsqlRelationalConnection connection,
            IRawSqlCommandBuilder rawSqlCommandBuilder,
            IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger)
        {
            var type = property.ClrType.UnwrapNullableType().UnwrapEnumType();

            if (type == typeof(long))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <long>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(int))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <int>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(short))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <short>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(byte))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <byte>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(char))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <char>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(ulong))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <ulong>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(uint))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <uint>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(ushort))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <ushort>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            if (type == typeof(sbyte))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <sbyte>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger));
            }

            throw new ArgumentException(CoreStrings.InvalidValueGeneratorFactoryProperty(
                                            nameof(NpgsqlSequenceValueGeneratorFactory), property.Name, property.DeclaringEntityType.DisplayName()));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual ValueGenerator Create(IProperty property, NpgsqlSequenceValueGeneratorState generatorState, INpgsqlRelationalConnection connection)
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(generatorState, nameof(generatorState));
            Check.NotNull(connection, nameof(connection));

            var type = property.ClrType.UnwrapNullableType().UnwrapEnumType();

            if (type == typeof(long))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <long>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(int))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <int>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(short))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <short>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(byte))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <byte>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(char))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <char>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(ulong))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <ulong>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(uint))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <uint>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(ushort))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <ushort>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            if (type == typeof(sbyte))
            {
                return(new NpgsqlSequenceHiLoValueGenerator <sbyte>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

            throw new ArgumentException(CoreStrings.InvalidValueGeneratorFactoryProperty(
                                            nameof(NpgsqlSequenceValueGeneratorFactory), property.Name, property.DeclaringEntityType.DisplayName()));
        }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public NpgsqlSequenceHiLoValueGenerator(
     [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
     [NotNull] IUpdateSqlGenerator sqlGenerator,
     [NotNull] NpgsqlSequenceValueGeneratorState generatorState,
     [NotNull] INpgsqlRelationalConnection connection,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger)
     : base(generatorState)
 {
     _sequence             = generatorState.Sequence;
     _rawSqlCommandBuilder = rawSqlCommandBuilder;
     _sqlGenerator         = sqlGenerator;
     _connection           = connection;
     _commandLogger        = commandLogger;
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public NpgsqlSequenceHiLoValueGenerator(
     IRawSqlCommandBuilder rawSqlCommandBuilder,
     IUpdateSqlGenerator sqlGenerator,
     NpgsqlSequenceValueGeneratorState generatorState,
     INpgsqlRelationalConnection connection,
     IRelationalCommandDiagnosticsLogger commandLogger)
     : base(generatorState)
 {
     _sequence             = generatorState.Sequence;
     _rawSqlCommandBuilder = rawSqlCommandBuilder;
     _sqlGenerator         = sqlGenerator;
     _connection           = connection;
     _commandLogger        = commandLogger;
 }
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public NpgsqlSequenceHiLoValueGenerator(
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] IUpdateSqlGenerator sqlGenerator,
            [NotNull] NpgsqlSequenceValueGeneratorState generatorState,
            [NotNull] INpgsqlRelationalConnection connection)
            : base(generatorState)
        {
            Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));
            Check.NotNull(sqlGenerator, nameof(sqlGenerator));
            Check.NotNull(connection, nameof(connection));

            _sequence             = generatorState.Sequence;
            _rawSqlCommandBuilder = rawSqlCommandBuilder;
            _sqlGenerator         = sqlGenerator;
            _connection           = connection;
        }