public async Task PersistSnapshotAsync(string actorName, long index, object snapshot) { try { using (var db = new SqlitePersistenceContext(_datasource)) { var item = new Snapshot(actorName, index, JsonConvert.SerializeObject(snapshot, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All })); await db.Snapshots.AddAsync(item); await db.SaveChangesAsync(); } } catch (Exception ex) { throw ex; } }
public async Task DeleteSnapshotsAsync(string actorName, long inclusiveToIndex) { try { using (var db = new SqlitePersistenceContext(_datasource)) { var items = db.Snapshots .Where(x => x.ActorName == actorName) .Where(x => x.SnapshotIndex <= inclusiveToIndex) .ToList(); db.RemoveRange(items); await db.SaveChangesAsync(); } } catch (Exception ex) { throw ex; } }