public User UndoMerge(AggregateStore <int> store, int userID, int mergeID) { var user = User.Blank(); var events = store.Replay("Users", userID); var mergeTransformations = new List <Transformation>(); user.LoadFromEvents(events.Apply(e => { var asMerge = e as IMergeEvent; var isMergeEvent = asMerge != null && asMerge.MergeID == mergeID; if (isMergeEvent) { MergeEvent(user, mergeTransformations, mergeID, e); } })); mergeTransformations .Where(t => t.HasChangedSinceMerge() == false) .Select(t => t.UndoEvent) .ForEach(e => user.PushEvent(e)); return(user); }