public Task <SnapShotResult <T> > LoadSnapShot <T>(string entityId) where T : new() { if (entityId == null) { return(Task.FromResult(SnapShotResult <T> .NotFound(null))); } if (!_snapShots.TryGetValue(entityId, out var entity)) { return(Task.FromResult(SnapShotResult <T> .Default())); } var snapShotWrapper = (SnapShotWrapper <T>)entity; return(Task.FromResult(new SnapShotResult <T>(snapShotWrapper.Entity, snapShotWrapper.Version))); }
public async Task <SnapShotResult <T> > LoadSnapShot <T>(string entityId) where T : new() { if (entityId == null) { return(SnapShotResult <T> .NotFound(null)); } var mongoCollection = _context.GetCollection <SnapShotDbo <T> >(_snapShotCollectionName); var asyncCursor = await mongoCollection.FindAsync(r => r.Id == entityId); var snapShot = asyncCursor.ToList().FirstOrDefault(); if (snapShot == null) { return(SnapShotResult <T> .Default()); } return(new SnapShotResult <T>(snapShot.Payload, snapShot.Version)); }