Write to soft-deleted stream with expectedVersion - How to get the lastEventNumber?

Hi everyone,

I am currently stuck trying to write to a previously soft-deleted stream.

  • We are using a non-admin user that has all permissions to read and write the stream and the metadata itself. ACLs are applied.

  • If we try to append messages with expectedVersion and expect the stream to be empty or non-existent, we get the WrongExpectedVersion error

How can we find out what the last event number was, so that we can properly set the expected version?

Thanks for your help and regards

Cedric

Hi!
I am having the same issue, have you found a solution?

Thx,

Thomas

When you load you events, use the event.EventNumber property to populated you Version number.

aggregate.Version = (AggregateVersion) historicEvent.EventNumber;

Hi,

indeed, had to read the event number from the stream and adjust the aggregate version accordingly.

Thx for the reply!