Example #1
0
        public virtual ValueGenerator Create(
            [NotNull] IProperty property,
            [NotNull] NpgsqlSequenceValueGeneratorState generatorState,
            [NotNull] INpgsqlEFConnection connection)
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(generatorState, nameof(generatorState));
            Check.NotNull(connection, nameof(connection));

            if (property.ClrType.UnwrapNullableType() == typeof(long))
            {
                return(new NpgsqlSequenceValueGenerator <long>(_executor, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(int))
            {
                return(new NpgsqlSequenceValueGenerator <int>(_executor, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(short))
            {
                return(new NpgsqlSequenceValueGenerator <short>(_executor, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(byte))
            {
                return(new NpgsqlSequenceValueGenerator <byte>(_executor, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ulong))
            {
                return(new NpgsqlSequenceValueGenerator <ulong>(_executor, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(uint))
            {
                return(new NpgsqlSequenceValueGenerator <uint>(_executor, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ushort))
            {
                return(new NpgsqlSequenceValueGenerator <ushort>(_executor, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(sbyte))
            {
                return(new NpgsqlSequenceValueGenerator <sbyte>(_executor, generatorState, connection));
            }

            throw new ArgumentException(Microsoft.Data.Entity.Internal.Strings.InvalidValueGeneratorFactoryProperty(
                                            nameof(NpgsqlSequenceValueGeneratorFactory), property.Name, property.EntityType.DisplayName()));
        }
Example #2
0
        public NpgsqlSequenceValueGenerator(
            [NotNull] SqlStatementExecutor executor,
            [NotNull] NpgsqlSequenceValueGeneratorState generatorState,
            [NotNull] INpgsqlEFConnection connection)
            : base(generatorState)
        {
            Check.NotNull(executor, nameof(executor));
            Check.NotNull(generatorState, nameof(generatorState));
            Check.NotNull(connection, nameof(connection));

            _sequenceName = generatorState.SequenceName;
            _executor     = executor;
            _connection   = connection;
        }
        public virtual ValueGenerator Create(IProperty property, NpgsqlSequenceValueGeneratorState generatorState, INpgsqlEFConnection connection)
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(generatorState, nameof(generatorState));
            Check.NotNull(connection, nameof(connection));

            if (property.ClrType.UnwrapNullableType() == typeof(long))
            {
                return new NpgsqlSequenceValueGenerator<long>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(int))
            {
                return new NpgsqlSequenceValueGenerator<int>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(short))
            {
                return new NpgsqlSequenceValueGenerator<short>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(byte))
            {
                return new NpgsqlSequenceValueGenerator<byte>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ulong))
            {
                return new NpgsqlSequenceValueGenerator<ulong>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(uint))
            {
                return new NpgsqlSequenceValueGenerator<uint>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ushort))
            {
                return new NpgsqlSequenceValueGenerator<ushort>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(sbyte))
            {
                return new NpgsqlSequenceValueGenerator<sbyte>(_executor, _sqlGenerator, generatorState, connection);
            }

            throw new ArgumentException(Microsoft.Data.Entity.Internal.Strings.InvalidValueGeneratorFactoryProperty(
                nameof(NpgsqlSequenceValueGeneratorFactory), property.Name, property.EntityType.DisplayName()));
        }