public async Task <Unit> Invoke(IStreamStore streamStore, CancellationToken ct) { var messageId = MessageId ?? (await streamStore.ReadStreamBackwards( StreamId, StreamVersion.GetValueOrDefault(-1), 1, true, ct)) .Messages.FirstOrDefault( message => StreamVersion == Streams.StreamVersion.End || message.StreamVersion == StreamVersion) .MessageId; await streamStore.DeleteMessage(StreamId, messageId, ct); return(Unit.Instance); }