Esempio n. 1
0
 /// <summary>
 /// Rolls back the active transaction.
 /// </summary>
 public override void Rollback()
 {
     CheckDisposed();
     SQLiteConnection.Check(_cnn);
     IsValid(true);
     IssueRollback(true);
 }
Esempio n. 2
0
        internal static void Check(SQLiteCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            command.CheckDisposed();
            SQLiteConnection.Check(command._cnn);
        }
Esempio n. 3
0
        /// <summary>
        /// Overrides the default behavior to return a SQLiteDataReader specialization class
        /// </summary>
        /// <param name="behavior">The flags to be associated with the reader.</param>
        /// <returns>A SQLiteDataReader</returns>
        public new SQLiteDataReader ExecuteReader(CommandBehavior behavior)
        {
            CheckDisposed();
            SQLiteConnection.Check(_cnn);
            InitializeForReader();

            SQLiteDataReader rd = new SQLiteDataReader(this, behavior);

            _activeReader = new WeakReference(rd, false);

            return(rd);
        }
Esempio n. 4
0
        /// <summary>
        /// Execute the command and return the first column of the first row of the resultset
        /// (if present), or null if no resultset was returned.
        /// </summary>
        /// <param name="behavior">The flags to be associated with the reader.</param>
        /// <returns>The first column of the first row of the first resultset from the query.</returns>
        public object ExecuteScalar(
            CommandBehavior behavior
            )
        {
            CheckDisposed();
            SQLiteConnection.Check(_cnn);

            using (SQLiteDataReader reader = ExecuteReader(behavior |
                                                           CommandBehavior.SingleRow | CommandBehavior.SingleResult))
            {
                if (reader.Read())
                {
                    return(reader[0]);
                }
            }
            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// Execute the command and return the number of rows inserted/updated affected by it.
        /// </summary>
        /// <param name="behavior">The flags to be associated with the reader.</param>
        /// <returns>The number of rows inserted/updated affected by it.</returns>
        public int ExecuteNonQuery(
            CommandBehavior behavior
            )
        {
            CheckDisposed();
            SQLiteConnection.Check(_cnn);

            using (SQLiteDataReader reader = ExecuteReader(behavior |
                                                           CommandBehavior.SingleRow | CommandBehavior.SingleResult))
            {
                while (reader.NextResult())
                {
                    ;
                }
                return(reader.RecordsAffected);
            }
        }
Esempio n. 6
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Commits the current transaction.
        /// </summary>
        public override void Commit()
        {
            CheckDisposed();
            SQLiteConnection.Check(_cnn);
            IsValid(true);

            if (_cnn._transactionLevel - 1 == 0)
            {
                using (SQLiteCommand cmd = _cnn.CreateCommand())
                {
                    cmd.CommandText = "COMMIT";
                    cmd.ExecuteNonQuery();
                }
            }
            _cnn._transactionLevel--;
            _cnn = null;
        }
Esempio n. 7
0
 /// <summary>
 /// Does nothing.  Commands are prepared as they are executed the first time, and kept in prepared state afterwards.
 /// </summary>
 public override void Prepare()
 {
     CheckDisposed();
     SQLiteConnection.Check(_cnn);
 }
Esempio n. 8
0
 /// <summary>
 /// Execute the command and return the first column of the first row of the resultset
 /// (if present), or null if no resultset was returned.
 /// </summary>
 /// <returns>The first column of the first row of the first resultset from the query.</returns>
 public override object ExecuteScalar()
 {
     CheckDisposed();
     SQLiteConnection.Check(_cnn);
     return(ExecuteScalar(CommandBehavior.Default));
 }
Esempio n. 9
0
 /// <summary>
 /// Execute the command and return the number of rows inserted/updated affected by it.
 /// </summary>
 /// <returns>The number of rows inserted/updated affected by it.</returns>
 public override int ExecuteNonQuery()
 {
     CheckDisposed();
     SQLiteConnection.Check(_cnn);
     return(ExecuteNonQuery(CommandBehavior.Default));
 }
Esempio n. 10
0
 /// <summary>
 /// Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class
 /// </summary>
 /// <returns>A SQLiteDataReader</returns>
 public new SQLiteDataReader ExecuteReader()
 {
     CheckDisposed();
     SQLiteConnection.Check(_cnn);
     return(ExecuteReader(CommandBehavior.Default));
 }