Esempio n. 1
0
        public virtual ValueGenerator Create(IProperty property, OracleSequenceValueGeneratorState generatorState, IOracleConnection 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 OracleSequenceHiLoValueGenerator <long>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }

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

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

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

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

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

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

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

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

            throw new ArgumentException(
                      CoreStrings.InvalidValueGeneratorFactoryProperty(
                          nameof(OracleSequenceValueGeneratorFactory), property.Name, property.DeclaringEntityType.DisplayName()));
        }
Esempio n. 2
0
        public OracleSequenceHiLoValueGenerator(
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] IUpdateSqlGenerator sqlGenerator,
            [NotNull] OracleSequenceValueGeneratorState generatorState,
            [NotNull] IOracleConnection 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;
        }