private static async Task <int?> GetStreamVersionAsync(IEventStream stream)
        {
            var metadata = await stream.TryGetMetadataAsync <int>(StreamVersionMetadataKey);

            return(metadata.isSuccessful ? metadata.value : default(int?));
        }