コード例 #1
0
        private void StoreSnapshotImpl <TSnapshot>(SqliteContext context, TSnapshot snapshot) where TSnapshot : EntitySnapshot
        {
            var snapshotSet = context.GetSnapshotSet <TSnapshot>();

            if (snapshotSet.Any(e => e.EntityID == snapshot.EntityID))
            {
                context.Update(snapshot);
            }
            else
            {
                context.Add(snapshot);
            }
        }
コード例 #2
0
 private IDisposable GetContext(out SqliteContext context)
 {
     if (_isBatching)
     {
         FlushBatch();
         context = _batchContext;
         return(Disposable.CreateEmpty());
     }
     else
     {
         context = new SqliteContext(_connection);
         return(context);
     }
 }
コード例 #3
0
        public IDisposable StartSnapshotStoreBatch()
        {
            if (_isBatching)
            {
                throw new InvalidOperationException("Cannot start batching while batching is already started");
            }
            _parentBatchContext = new SqliteContext(_connection);
            _transaction        = _parentBatchContext.Database.BeginTransaction();

            _batchContext = new SqliteContext(_connection);
            _batchContext.Database.UseTransaction(_transaction.GetDbTransaction());

            _isBatching = true;
            return(Disposable.Create(StopBatching));
        }
コード例 #4
0
 private void StoreSnapshotsImpl(SqliteContext context, IEnumerable <EntitySnapshot> snapshots)
 {
     foreach (var snapshot in snapshots)
     {
         var dbSnapshot = context.Find(snapshot.GetType(), snapshot.EntityID);
         if (dbSnapshot != null)
         {
             context.Update(snapshot);
         }
         else
         {
             context.Add(snapshot);
         }
     }
 }