Skip to content

How to manually set the mt_events.id property #3632

Answered by mumby0168
mumby0168 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks @jeremydmiller I just created this small extension method and it's working as I'd hoped :)

public static class EventStoreExtensions
    {
        public static StreamAction AppendWithId<T>(this IEventStore eventStore, string streamId, T evt, Func<T, Guid> idFunc) where T : class
        {
            var stream = eventStore.Append(streamId, evt);
            stream.Events.Single().Id = idFunc(evt);
            return stream;
        }
    }

how do you feel about either this or something similar been contributed to the library?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mumby0168
Comment options

Answer selected by jeremydmiller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3631 on January 18, 2025 01:33.