public void MergeCommands(IEnumerable <CommandDto> commands) { // todo: replay should be done once for each unique entity, or we need to refresh // the existing entity for every command foreach (var command in commands) { // cheap solution. Should find a way to wrap the state here as well. var states = _repo.GetCommandStates(command.EntityGuid);//.Select(s => new CommandDto { Guid = s.Guid, Entity = command.Entity, EntityGuid = s.EntityGuid, Name = s.CommandTypeId.Replace(command.Entity + "Command", ""), ParametersJson = s.ParametersJson, CreatedOn = s.CreatedOn }); foreach (var state in states) { // these will always be the same Entity ProcessCommand(command, state); } ProcessCommand(command); } }