Number of events in one stream?

can i use event revision as number of events in the one stream?
if not how can i count number of events in one stream?

I have done this:

    private static async Task<StreamPosition> GetEndStreamPosition(EventStoreClient client, String stream,CancellationToken cancellationToken) {

        EventStoreClient.ReadStreamResult readStreamResult = client.ReadStreamAsync(
                                                                                    Direction.Backwards,
                                                                                    stream,
                                                                                    StreamPosition.End,
                                                                                    cancellationToken: cancellationToken);

        await foreach (ResolvedEvent e in readStreamResult) {
            streamPosition = e.OriginalEventNumber;
            break;
        }

        return streamPosition;
    }
1 Like

this means the latest event number is the number of total events in one stream right?

If you are using OriginalEventNumber, I think so.

1 Like

Not if the stream was truncated. You need both positions of the first and last event, and the difference between them will give you the actual number of events.