public TestDatabaseCreator(
     RelationalDatabaseCreatorDependencies dependencies,
     IOracleConnection connection,
     IRawSqlCommandBuilder rawSqlCommandBuilder)
     : base(dependencies, connection, rawSqlCommandBuilder)
 {
 }
 public OracleDatabaseCreator(
     [NotNull] RelationalDatabaseCreatorDependencies dependencies,
     [NotNull] IOracleConnection connection,
     [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder)
     : base(dependencies)
 {
     _connection           = connection;
     _rawSqlCommandBuilder = rawSqlCommandBuilder;
 }
        public OracleValueGeneratorSelector(
            [NotNull] ValueGeneratorSelectorDependencies dependencies,
            [NotNull] IOracleSequenceValueGeneratorFactory sequenceFactory,
            [NotNull] IOracleConnection connection)
            : base(dependencies)
        {
            Check.NotNull(sequenceFactory, nameof(sequenceFactory));
            Check.NotNull(connection, nameof(connection));

            _sequenceFactory = sequenceFactory;
            _connection      = connection;
        }
 /// <summary>
 /// 实例化HiLoValue生成器
 /// </summary>
 /// <param name="rawSqlCommandBuilder">RawSql命令创建器</param>
 /// <param name="sqlGenerator">UpdateSql生成器</param>
 /// <param name="generatorState">序列值生成器状态</param>
 /// <param name="connection">连接对象</param>
 public OracleSequenceHiLoValueGenerator(
     [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
     [NotNull] IUpdateSqlGenerator sqlGenerator,
     [NotNull] OracleSequenceValueGeneratorState generatorState,
     [NotNull] IOracleConnection connection)
     : base((HiLoValueGeneratorState)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;
 }
Пример #5
0
        /// <summary>
        /// 实例化值生成器选择器
        /// </summary>
        /// <param name="dependencies">值生成器选择器依赖</param>
        /// <param name="sequenceFactory">序列值生成器工厂</param>
        /// <param name="connection">连接对象</param>
        /// <param name="logger">日志</param>
        public OracleValueGeneratorSelector(
            [NotNull] ValueGeneratorSelectorDependencies dependencies,
            [NotNull] IOracleSequenceValueGeneratorFactory sequenceFactory,
            [NotNull] IOracleConnection connection,
            IDiagnosticsLogger <DbLoggerCategory.Update> logger = null)
            : base(dependencies)
        {
            if (Check.IsTraceEnabled(logger?.Logger))
            {
                Trace <DbLoggerCategory.Update> .Write(logger, LogLevel.Trace, OracleTraceTag.Entry, OracleTraceClassName.OracleValueGeneratorSelector, OracleTraceFuncName.ctor);
            }

            Check.NotNull(sequenceFactory, nameof(sequenceFactory));
            Check.NotNull(connection, nameof(connection));
            _sequenceFactory = sequenceFactory;
            _connection      = connection;
            m_oracleLogger   = logger;

            if (Check.IsTraceEnabled(logger?.Logger))
            {
                Trace <DbLoggerCategory.Update> .Write(logger, LogLevel.Trace, OracleTraceTag.Exit, OracleTraceClassName.OracleValueGeneratorSelector, OracleTraceFuncName.ctor);
            }
        }
Пример #6
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()));
        }
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="property">属性</param>
        /// <param name="generatorState">序列值生成器状态</param>
        /// <param name="connection">连接对象</param>
        /// <returns></returns>
        public virtual ValueGenerator Create(
            IProperty property,
            OracleSequenceValueGeneratorState generatorState,
            IOracleConnection connection)
        {
            try
            {
                if (Check.IsTraceEnabled(m_oracleLogger?.Logger))
                {
                    Trace <DbLoggerCategory.Update> .Write(m_oracleLogger, LogLevel.Trace, OracleTraceTag.Entry, OracleTraceClassName.OracleSequenceValueGeneratorFactory, OracleTraceFuncName.Create);
                }

                Check.NotNull(property, nameof(property));
                Check.NotNull(generatorState, nameof(generatorState));
                Check.NotNull(connection, nameof(connection));

                Type 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)))
                {
                    throw new ArgumentException(CoreStrings.InvalidValueGeneratorFactoryProperty("OracleSequenceValueGeneratorFactory", property.Name, property.DeclaringEntityType.DisplayName()));
                }
                return(new OracleSequenceHiLoValueGenerator <sbyte>(_rawSqlCommandBuilder, _sqlGenerator, generatorState, connection));
            }
            catch (Exception ex)
            {
                if (Check.IsErrorEnabled(m_oracleLogger?.Logger))
                {
                    Trace <DbLoggerCategory.Update> .Write(m_oracleLogger, LogLevel.Error, OracleTraceTag.Error, OracleTraceClassName.OracleSequenceValueGeneratorFactory, OracleTraceFuncName.Create, ex.ToString());
                }
                throw;
            }
            finally
            {
                if (Check.IsTraceEnabled(m_oracleLogger?.Logger))
                {
                    Trace <DbLoggerCategory.Update> .Write(m_oracleLogger, LogLevel.Trace, OracleTraceTag.Exit, OracleTraceClassName.OracleSequenceValueGeneratorFactory, OracleTraceFuncName.Create);
                }
            }
        }
Пример #8
0
 protected TestOracleConnection(IOracleConnection connection)
 => _realConnection = connection;