public static NpgsqlParameter DeletedStreamMessage(PostgresqlStreamId streamId)
 {
     return(new NpgsqlParameter <PostgresNewStreamMessage>
     {
         TypedValue = PostgresNewStreamMessage.FromNewStreamMessage(
             Deleted.CreateStreamDeletedMessage(streamId.IdOriginal))
     });
 }
        private async Task DeleteStreamInternal(
            MySqlStreamId streamId,
            int expectedVersion,
            MySqlTransaction transaction,
            CancellationToken cancellationToken)
        {
            var deletedStreamMessage = Deleted.CreateStreamDeletedMessage(streamId.IdOriginal);

            var deletedStreamId               = Parameters.DeletedStreamId();
            var deletedStreamIdOriginal       = Parameters.DeletedStreamIdOriginal();
            var deletedMetadataStreamId       = Parameters.DeletedMetadataStreamId();
            var deletedStreamMessageMessageId = Parameters.DeletedStreamMessageMessageId(deletedStreamMessage);
            var deletedStreamMessageType      = Parameters.DeletedStreamMessageType(deletedStreamMessage);
            var deletedStreamMessageJsonData  = Parameters.DeletedStreamMessageJsonData(deletedStreamMessage);

            using (var command = BuildStoredProcedureCall(
                       _schema.DeleteStream,
                       transaction,
                       Parameters.StreamId(streamId),
                       Parameters.ExpectedVersion(expectedVersion),
                       Parameters.CreatedUtc(_settings.GetUtcNow?.Invoke()),
                       Parameters.DeletionTrackingDisabled(_settings.DisableDeletionTracking),
                       _settings.DisableDeletionTracking ? deletedStreamId.Empty() : deletedStreamId,
                       _settings.DisableDeletionTracking ? deletedStreamIdOriginal.Empty() : deletedStreamIdOriginal,
                       _settings.DisableDeletionTracking ? deletedMetadataStreamId.Empty() : deletedMetadataStreamId,
                       _settings.DisableDeletionTracking
                    ? deletedStreamMessageMessageId.Empty()
                    : deletedStreamMessageMessageId,
                       _settings.DisableDeletionTracking ? deletedStreamMessageType.Empty() : deletedStreamMessageType,
                       _settings.DisableDeletionTracking
                    ? deletedStreamMessageJsonData.Empty()
                    : deletedStreamMessageJsonData))
            {
                try
                {
                    await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
                }
                catch (MySqlException ex) when(ex.IsWrongExpectedVersion())
                {
                    await transaction.RollbackAsync(cancellationToken).ConfigureAwait(false);

                    throw new WrongExpectedVersionException(
                              ErrorMessages.DeleteStreamFailedWrongExpectedVersion(streamId.IdOriginal, expectedVersion),
                              streamId.IdOriginal,
                              expectedVersion,
                              ex);
                }
            }
        }