Example #1
0
        /// <summary>
        /// Drops the database/schema with the given name.
        /// </summary>
        /// <param name="schema">The name of the schema.</param>
        /// <exception cref="ArgumentNullException"><paramref name="schema"/> is null.</exception>
        public void DropSchema(string schema)
        {
            if (string.IsNullOrWhiteSpace(schema))
            {
                throw new ArgumentNullException(nameof(schema));
            }
            Schema s = this.GetSchema(schema);

            if (!s.ExistsInDatabase())
            {
                return;
            }
            InternalSession.ExecuteSqlNonQuery("DROP DATABASE `" + schema + "`");
        }
Example #2
0
 /// <summary>
 /// Rolls back a transaction to the named savepoint without terminating the transaction.
 /// </summary>
 /// <param name="name">The name of the transaction savepoint.</param>
 public void RollbackTo(string name)
 {
     InternalSession.ExecuteSqlNonQuery($"ROLLBACK TO {name}");
 }
Example #3
0
 /// <summary>
 /// Removes the named savepoint from the set of savepoints within the current transaction.
 /// </summary>
 /// <param name="name">The name of the transaction savepoint.</param>
 public void ReleaseSavepoint(string name)
 {
     InternalSession.ExecuteSqlNonQuery($"RELEASE SAVEPOINT {name}");
 }
Example #4
0
 /// <summary>
 /// Sets a named transaction savepoint.
 /// </summary>
 /// <param name="name">The name of the transaction savepoint.</param>
 /// <returns>The name of the transaction savepoint.</returns>
 public string SetSavepoint(string name)
 {
     InternalSession.ExecuteSqlNonQuery($"SAVEPOINT {name}");
     return(name);
 }
Example #5
0
 /// <summary>
 /// Rolls back the current transaction.
 /// </summary>
 public void Rollback()
 {
     InternalSession.ExecuteSqlNonQuery("ROLLBACK");
 }
Example #6
0
 /// <summary>
 /// Commits the current transaction.
 /// </summary>
 /// <returns>A <see cref="Result"/> object containing the results of the commit operation.</returns>
 public void Commit()
 {
     InternalSession.ExecuteSqlNonQuery("COMMIT");
 }
Example #7
0
 /// <summary>
 /// Starts a new transaction.
 /// </summary>
 public void StartTransaction()
 {
     InternalSession.ExecuteSqlNonQuery("START TRANSACTION");
 }
Example #8
0
 /// <summary>
 /// Creates a schema/database with the given name.
 /// </summary>
 /// <param name="schema">The name of the schema/database.</param>
 /// <returns>A <see cref="Schema"/> object that matches the recently created schema/database.</returns>
 public Schema CreateSchema(string schema)
 {
     InternalSession.ExecuteSqlNonQuery("CREATE DATABASE `" + schema + "`");
     return(new Schema(this, schema));
 }
Example #9
0
 /// <summary>
 /// Rolls back the current transaction.
 /// </summary>
 public Result Rollback()
 {
     return(InternalSession.ExecuteSqlNonQuery("ROLLBACK"));
 }
Example #10
0
 /// <summary>
 /// Commits the current transaction.
 /// </summary>
 /// <returns>A <see cref="Result"/> object containing the results of the commit operation.</returns>
 public Result Commit()
 {
     return(InternalSession.ExecuteSqlNonQuery("COMMIT"));
 }
Example #11
0
 /// <summary>
 /// Sets the schema in the database.
 /// </summary>
 /// <param name="schema">The schema name to be set.</param>
 public void SetCurrentSchema(string schema)
 {
     InternalSession.ExecuteSqlNonQuery($"USE `{schema}`");
     GetSchema(schema);
 }