Ejemplo n.º 1
0
        public override void Begin()
        {
            SQLiteDatabase sqliteDatabase = this.database as SQLiteDatabase;

            this.connection = new SqliteConnection(sqliteDatabase.ConnectionString);
            this.connection.Open();
            this.transaction = this.connection.BeginTransaction();
        }
Ejemplo n.º 2
0
        public override async Task BeginAsync()
        {
            SQLiteDatabase sqliteDatabase = this.database as SQLiteDatabase;

            this.connection = new SqliteConnection(sqliteDatabase.ConnectionString);
            await this.connection.OpenAsync();

            this.transaction = this.connection.BeginTransaction();
        }
Ejemplo n.º 3
0
        private SqliteTestStore CreateShared(Action initializeDatabase)
        {
            CreateShared(typeof(SqliteTestStore).Name + _name, initializeDatabase);

            CreateAndOpenConnection();

            _transaction = _connection.BeginTransaction();

            return this;
        }
        private SqliteTestStore CreateShared(Action initializeDatabase)
        {
            CreateShared(typeof(SqliteTestStore).Name + _name, initializeDatabase);

            _connection = new SqliteConnection(CreateConnectionString(_name));

            _connection.Open();
            _transaction = _connection.BeginTransaction();

            return this;
        }
Ejemplo n.º 5
0
        public new virtual SqliteTransaction BeginTransaction(IsolationLevel isolationLevel)
        {
            if (State != ConnectionState.Open)
            {
                throw new InvalidOperationException(Strings.FormatCallRequiresOpenConnection("BeginTransaction"));
            }
            if (Transaction != null)
            {
                throw new InvalidOperationException(Strings.ParallelTransactionsNotSupported);
            }

            return(Transaction = new SqliteTransaction(this, isolationLevel, SqliteCommand.DefaultCommandTimeout));
        }
 /// <summary>
 /// Closes the connection to the database. Open transactions are rolled back.
 /// </summary>
 public override void Close()
 {
     if (this._db == null || this._db.ptr == IntPtr.Zero)
         return;
     SqliteTransaction transaction = this.Transaction;
     if (transaction != null)
     {
         // ISSUE: explicit non-virtual call
         transaction.Dispose() ;
     }
     this._db.Dispose();
     this._db = (sqlite3)null;
     this.SetState(ConnectionState.Closed);
 }
Ejemplo n.º 7
0
        private static void PrepareCommand(
            SqliteCommand command,
            SqliteConnection connection,
            SqliteTransaction transaction,
            CommandType commandType,
            string commandText,
            DbParameter[] commandParameters)
        {
            if (command == null) throw new ArgumentNullException("command");
            if (string.IsNullOrEmpty(commandText)) throw new ArgumentNullException("commandText");

            command.CommandType = commandType;
            command.CommandText = commandText;
            command.Connection = connection;

            if (transaction != null)
            {
                if (transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
                command.Transaction = transaction;
            }

            if (commandParameters != null) { AttachParameters(command, commandParameters); }
        }
Ejemplo n.º 8
0
 public SqliteCommand(string commandText, SqliteConnection connection, SqliteTransaction transaction)
     : this(commandText, connection)
 {
     Transaction = transaction;
 }
Ejemplo n.º 9
0
 public SqliteCommand(string commandText, SqliteConnection connection, SqliteTransaction transaction)
     : this(commandText, connection)
 {
     Transaction = transaction;
 }
Ejemplo n.º 10
0
        public static int ExecuteNonQuery(
            SqliteTransaction transaction,
            CommandType commandType,
            string commandText,
            int commandTimeout,
            params DbParameter[] commandParameters)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");

            var factory = GetFactory();

            using (SqliteCommand command = factory.CreateCommand())
            {
                PrepareCommand(
                    command,
                    transaction.Connection,
                    transaction,
                    commandType,
                    commandText,
                    commandParameters);

                command.CommandTimeout = commandTimeout;

                return command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 11
0
        public static int ExecuteNonQuery(
            SqliteTransaction transaction,
            CommandType commandType,
            string commandText,
            params DbParameter[] commandParameters)
        {
            int commandTimeout = 30; //30 seconds default

            return ExecuteNonQuery(transaction, commandType, commandText, commandTimeout, commandParameters);


        }
        public new virtual SqliteTransaction BeginTransaction(IsolationLevel isolationLevel)
        {
            if (State != ConnectionState.Open)
            {
                throw new InvalidOperationException(Strings.FormatCallRequiresOpenConnection("BeginTransaction"));
            }
            if (Transaction != null)
            {
                throw new InvalidOperationException(Strings.ParallelTransactionsNotSupported);
            }

            return Transaction = new SqliteTransaction(this, isolationLevel);
        }