/// <summary>
    /// Initializes a new instance of the <see cref="MySqlTransactionalDataSource"/> 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 MySqlTransactionalDataSource(MySqlDataSource dataSource, IsolationLevel?isolationLevel, bool forwardEvents)
        : base(new MySqlDataSourceSettings(dataSource, forwardEvents))
    {
        Name = dataSource.Name;

        m_BaseDataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null.");
        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="MySqlTransactionalDataSource"/> 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 MySqlTransactionalDataSource(MySqlDataSource dataSource, IsolationLevel?isolationLevel, bool forwardEvents)
            : base(new MySqlDataSourceSettings {
            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="MySqlTransactionalDataSource" /> 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 MySqlTransactionalDataSource(MySqlDataSource dataSource, bool forwardEvents, MySqlConnection connection, MySqlTransaction transaction)
        : base(new MySqlDataSourceSettings(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;
    }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MySqlTransactionalDataSource" /> 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 MySqlTransactionalDataSource(MySqlDataSource dataSource, bool forwardEvents, MySqlConnection connection, MySqlTransaction transaction)
            : base(new MySqlDataSourceSettings {
            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;
        }