diff --git a/src/SIL.Harmony/Changes/ChangeContext.cs b/src/SIL.Harmony/Changes/ChangeContext.cs index 3929999..15c10d7 100644 --- a/src/SIL.Harmony/Changes/ChangeContext.cs +++ b/src/SIL.Harmony/Changes/ChangeContext.cs @@ -17,6 +17,12 @@ internal ChangeContext(Commit commit, SnapshotWorker worker, CrdtConfig crdtConf public Commit Commit { get; } public async ValueTask GetSnapshot(Guid entityId) => await _worker.GetSnapshot(entityId); + public async ValueTask GetCurrent(Guid entityId) where T : class + { + var snapshot = await GetSnapshot(entityId); + if (snapshot is null) return null; + return (T) snapshot.Entity.DbObject; + } public async ValueTask IsObjectDeleted(Guid entityId) => (await GetSnapshot(entityId))?.EntityIsDeleted ?? true; internal IObjectBase Adapt(object obj) => _crdtConfig.ObjectTypeListBuilder.AdapterProvider.Adapt(obj);