internal SQLiteServerTransaction(SQLiteServerConnection connection) { if (null == connection) { throw new ArgumentNullException(nameof(connection)); } _connection = connection; }
public SQLiteServerCommand(string commandText, SQLiteServerConnection connection) { _connection = connection; CommandText = commandText; // set the connection timeout var builder = new SQLiteServerConnectionStringBuilder(connection?.ConnectionString); CommandTimeout = builder.DefaultTimeout; }
internal SQLiteServerDataReader(ISQLiteServerDataReaderWorker worker, SQLiteServerConnection connection, CommandBehavior commandBehavior) { if (null == worker) { throw new ArgumentNullException(nameof(worker), "The worker cannot be null"); } _worker = worker; _connection = connection; _commandBehavior = commandBehavior; }
/// <summary> /// Backup the database /// </summary> /// <param name="destination"></param> /// <param name="destinationName"></param> /// <param name="sourceName"></param> /// <param name="pages"></param> /// <param name="callback"></param> /// <param name="retryMilliseconds"></param> public void BackupDatabase( SQLiteServerConnection destination, string destinationName, string sourceName, int pages, SQLiteServerBackupCallback callback, int retryMilliseconds) { // check not disposed ThrowIfAny(); // check destination is valid. if (destination == null) { throw new ArgumentNullException(nameof(destination)); } if (destination.State != ConnectionState.Open) { throw new InvalidOperationException("Destination database is not open."); } // validate the names if (destinationName == null) { throw new ArgumentNullException(nameof(destinationName)); } if (sourceName == null) { throw new ArgumentNullException(nameof(sourceName)); } // convert the callback to sqlite callback // but only if the caller gave us a callback. var callback2 = callback == null ? null : new SQLiteBackupCallback( (source2, sourceName2, destination2, destinationName2, pages2, remainingPages, totalPages, retry) => callback(this, sourceName2, destination, destinationName2, pages2, remainingPages, totalPages, retry)); try { // get the sqlite connections. Task.Run(async() => { var sourceConnection = await _worker.LockConnectionAsync().ConfigureAwait(false); var destinationConnection = await destination._worker.LockConnectionAsync().ConfigureAwait(false); // Call the SQlite connection. sourceConnection.BackupDatabase(destinationConnection, destinationName, sourceName, pages, callback2, retryMilliseconds); }).Wait(); } finally { Task.Run(async() => { await _worker.UnLockConnectionAsync().ConfigureAwait(false); await destination._worker.UnLockConnectionAsync().ConfigureAwait(false); }).Wait(); } }
public SQLiteServerCommand(SQLiteServerConnection connection) : this(null, connection) { }