Reputation: 345
"Marten does need to know what the event types are before you issue queries against the event data"
But I do for example
session.Events.FetchStream(streamId)
and
session.Events.Load<MembersJoined>()
and they works fine
thanks
Upvotes: 3
Views: 132
Reputation: 9588
I have found that, in practice, if your application commits events to Marten prior to reading any streams, you don't have to register any events.
If, however, you wind up reading streams prior to committing anything, you need to configure your events first. My application conditionally rebuilds projections on startup prior to accepting input, so it wound up causing this problem.
When configuring Marten, pass in an IEnumerable<Type>
of all your event types. For instance, my registration looks like this:
cfg.Events.AddEventTypes(
typeof(EventBase)
.Assembly
.GetTypes()
.Where(typeof(EventBase).IsAssignableFrom)
);
I recommend using a base class for all events as it makes things like this super simple.
Having configured Marten with those events, you are now free to query streams as you need to.
Upvotes: 1