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); } }
private IDisposable GetContext(out SqliteContext context) { if (_isBatching) { FlushBatch(); context = _batchContext; return(Disposable.CreateEmpty()); } else { context = new SqliteContext(_connection); return(context); } }
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)); }
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); } } }