public AS400SequenceHiLoValueGenerator(
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] IAS400UpdateSqlGenerator sqlGenerator,
            [NotNull] AS400SequenceValueGeneratorState generatorState,
            [NotNull] IAS400RelationalConnection 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;
        }
Ejemplo n.º 2
0
        public virtual ValueGenerator Create(IProperty property, AS400SequenceValueGeneratorState generatorState, IAS400RelationalConnection 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 AS400SequenceHiLoValueGenerator <long>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(int))
            {
                return(new AS400SequenceHiLoValueGenerator <int>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(short))
            {
                return(new AS400SequenceHiLoValueGenerator <short>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(byte))
            {
                return(new AS400SequenceHiLoValueGenerator <byte>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(char))
            {
                return(new AS400SequenceHiLoValueGenerator <char>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(ulong))
            {
                return(new AS400SequenceHiLoValueGenerator <ulong>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(uint))
            {
                return(new AS400SequenceHiLoValueGenerator <uint>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(ushort))
            {
                return(new AS400SequenceHiLoValueGenerator <ushort>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            if (type == typeof(sbyte))
            {
                return(new AS400SequenceHiLoValueGenerator <sbyte>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            throw new ArgumentException(CoreStrings.InvalidValueGeneratorFactoryProperty(
                                            nameof(AS400SequenceValueGeneratorFactory), property.Name, property.DeclaringEntityType.DisplayName()));
        }