/// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTransactionalDataSource"/> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        /// <param name="forwardEvents">if set to <c>true</c> [forward events].</param>
        public PostgreSqlTransactionalDataSource(PostgreSqlDataSource dataSource, IsolationLevel?isolationLevel, bool forwardEvents)
            : base(new PostgreSqlDataSourceSettings {
            DefaultCommandTimeout = dataSource.DefaultCommandTimeout, StrictMode = dataSource.StrictMode, SuppressGlobalEvents = dataSource.SuppressGlobalEvents || forwardEvents
        })
        {
            Name = dataSource.Name;

            m_BaseDataSource = dataSource;
            m_Connection     = dataSource.CreateConnection();

            if (isolationLevel == null)
            {
                m_Transaction = m_Connection.BeginTransaction();
            }
            else
            {
                m_Transaction = m_Connection.BeginTransaction(isolationLevel.Value);
            }

            if (forwardEvents)
            {
                ExecutionStarted  += (sender, e) => dataSource.OnExecutionStarted(e);
                ExecutionFinished += (sender, e) => dataSource.OnExecutionFinished(e);
                ExecutionError    += (sender, e) => dataSource.OnExecutionError(e);
                ExecutionCanceled += (sender, e) => dataSource.OnExecutionCanceled(e);
            }
            AuditRules = dataSource.AuditRules;
            UserValue  = dataSource.UserValue;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTransactionalDataSource"/> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        /// <param name="forwardEvents">if set to <c>true</c> [forward events].</param>
        public PostgreSqlTransactionalDataSource(PostgreSqlDataSource dataSource, IsolationLevel?isolationLevel, bool forwardEvents)
            : base(new PostgreSqlDataSourceSettings(dataSource, forwardEvents))
        {
            Name = dataSource.Name;

            m_BaseDataSource = dataSource;
            m_Connection     = dataSource.CreateConnection();

            if (isolationLevel == null)
            {
                m_Transaction = m_Connection.BeginTransaction();
            }
            else
            {
                m_Transaction = m_Connection.BeginTransaction(isolationLevel.Value);
            }

            if (forwardEvents)
            {
                ExecutionStarted  += (sender, e) => dataSource.OnExecutionStarted(e);
                ExecutionFinished += (sender, e) => dataSource.OnExecutionFinished(e);
                ExecutionError    += (sender, e) => dataSource.OnExecutionError(e);
                ExecutionCanceled += (sender, e) => dataSource.OnExecutionCanceled(e);
            }
            AuditRules = dataSource.AuditRules;
            UserValue  = dataSource.UserValue;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTransactionalDataSource" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="forwardEvents">if set to <c>true</c> [forward events].</param>
        /// <param name="connection">The connection.</param>
        /// <param name="transaction">The transaction.</param>
        internal PostgreSqlTransactionalDataSource(PostgreSqlDataSource dataSource, bool forwardEvents, NpgsqlConnection connection, NpgsqlTransaction transaction)
            : base(new PostgreSqlDataSourceSettings(dataSource, forwardEvents))
        {
            Name = dataSource.Name;

            m_BaseDataSource = dataSource;
            m_Connection     = connection;
            m_Transaction    = transaction;

            if (forwardEvents)
            {
                ExecutionStarted  += (sender, e) => dataSource.OnExecutionStarted(e);
                ExecutionFinished += (sender, e) => dataSource.OnExecutionFinished(e);
                ExecutionError    += (sender, e) => dataSource.OnExecutionError(e);
                ExecutionCanceled += (sender, e) => dataSource.OnExecutionCanceled(e);
            }
            AuditRules = dataSource.AuditRules;
            UserValue  = dataSource.UserValue;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTransactionalDataSource" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="forwardEvents">if set to <c>true</c> [forward events].</param>
        /// <param name="connection">The connection.</param>
        /// <param name="transaction">The transaction.</param>
        internal PostgreSqlTransactionalDataSource(PostgreSqlDataSource dataSource, bool forwardEvents, NpgsqlConnection connection, NpgsqlTransaction transaction)
            : base(new PostgreSqlDataSourceSettings {
            DefaultCommandTimeout = dataSource.DefaultCommandTimeout, StrictMode = dataSource.StrictMode, SuppressGlobalEvents = dataSource.SuppressGlobalEvents || forwardEvents
        })
        {
            Name = dataSource.Name;

            m_BaseDataSource = dataSource;
            m_Connection     = connection;
            m_Transaction    = transaction;

            if (forwardEvents)
            {
                ExecutionStarted  += (sender, e) => dataSource.OnExecutionStarted(e);
                ExecutionFinished += (sender, e) => dataSource.OnExecutionFinished(e);
                ExecutionError    += (sender, e) => dataSource.OnExecutionError(e);
                ExecutionCanceled += (sender, e) => dataSource.OnExecutionCanceled(e);
            }
            AuditRules = dataSource.AuditRules;
            UserValue  = dataSource.UserValue;
        }