示例#1
0
        /// <summary>
        /// Starts a database transaction.
        /// </summary>
        /// <param name="isolationLevel">Specifies the isolation level for the transaction.</param>
        /// <returns>
        /// An object representing the new transaction.
        /// </returns>
        protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
        {
            if (State != ConnectionState.Open)
            {
                throw new InvalidOperationException(Messages.CannotCallMethodInThisConnectionState("BeginDbTransaction", State));
            }

            if (ActiveTransaction != null)
            {
                throw new InvalidOperationException(Messages.UnsupportedParallelTransactions());
            }

            switch (isolationLevel)
            {
            case IsolationLevel.Serializable:
                ActiveTransaction = new JetTransaction(InnerConnection.BeginTransaction(IsolationLevel.ReadCommitted), this);
                break;

            default:
                ActiveTransaction = new JetTransaction(InnerConnection.BeginTransaction(isolationLevel), this);
                break;
            }

            return(ActiveTransaction);
        }
 private void Initialize(string commandText, JetConnection connection, DbTransaction transaction)
 {
     _Connection        = null;
     _Transaction       = null;
     _DesignTimeVisible = true;
     _WrappedCommand    = new OleDbCommand();
     this.CommandText   = commandText;
     this.Connection    = connection;
     this.Transaction   = transaction;
 }