Exemplo n.º 1
0
 private void FlushBatch()
 {
     _batchContext.SaveChanges();
     _batchContext.Dispose();
     _batchContext = new SqliteContext(_connection);
     _batchContext.Database.UseTransaction(_transaction.GetDbTransaction());
 }
Exemplo n.º 2
0
        private void StopBatching()
        {
            if (!_isBatching)
            {
                throw new InvalidOperationException("Cannot stop batching while batching is not started");
            }

            FlushBatch();

            if (_lastVectorClockCache != null)
            {
                SetLastVectorClockImpl(_lastVectorClockCache);
            }

            _batchContext.SaveChanges();
            _batchContext.Dispose();

            _transaction.Commit();
            _transaction.Dispose();

            _parentBatchContext.SaveChanges();
            _parentBatchContext.Dispose();

            _transaction          = null;
            _batchContext         = null;
            _parentBatchContext   = null;
            _lastVectorClockCache = null;
            _isBatching           = false;
            _batchCount           = 0;

            var cmd = _connection.CreateCommand();

            cmd.CommandText = "PRAGMA wal_checkpoint;";
            cmd.ExecuteNonQuery();
        }