diff --git a/.gitignore b/.gitignore index 20026421f0..2a5109d139 100644 --- a/.gitignore +++ b/.gitignore @@ -230,6 +230,7 @@ stresults.htm docs/.vitepress/dist docs/.vitepress/cache +docs/public/freight-shipping-tutorial.zip src/CommandLineRunner/Internal/* diff --git a/src/EventSourcingTests/Dcb/dcb_boundary_aggregate_fetch_for_writing_tests.cs b/src/EventSourcingTests/Dcb/dcb_boundary_aggregate_fetch_for_writing_tests.cs index 8646137fec..dd01a553ee 100644 --- a/src/EventSourcingTests/Dcb/dcb_boundary_aggregate_fetch_for_writing_tests.cs +++ b/src/EventSourcingTests/Dcb/dcb_boundary_aggregate_fetch_for_writing_tests.cs @@ -91,3 +91,48 @@ public async Task fetch_for_writing_by_tags_works_for_pure_boundary_aggregate() boundary.Events.Count.ShouldBe(2); } } + +// Same setup as the sibling fixture but without overriding StreamIdentity, +// covering the default AsGuid path. +[Collection("OneOffs")] +public class dcb_boundary_aggregate_default_stream_identity_tests: OneOffConfigurationsContext, IAsyncLifetime +{ + private void ConfigureStore() + { + StoreOptions(opts => + { + opts.Events.AddEventType(); + opts.Events.AddEventType(); + + opts.Events.RegisterTagType("enrollee").ForAggregate(); + opts.Events.RegisterTagType("program").ForAggregate(); + }); + } + + public Task InitializeAsync() + { + ConfigureStore(); + return Task.CompletedTask; + } + + public Task DisposeAsync() => Task.CompletedTask; + + [Fact] + public async Task fetch_for_writing_by_tags_works_with_default_guid_stream_identity() + { + var enrolleeId = new EnrolleeId(Guid.NewGuid()); + + var enrolled = theSession.Events.BuildEvent(new Enrolled("Bob")); + enrolled.WithTag(enrolleeId); + theSession.Events.Append(Guid.NewGuid(), enrolled); + + await theSession.SaveChangesAsync(); + + await using var session = theStore.LightweightSession(); + var query = new EventTagQuery().Or(enrolleeId); + var boundary = await session.Events.FetchForWritingByTags(query); + + boundary.Aggregate.ShouldNotBeNull(); + boundary.Aggregate!.EnrollmentCount.ShouldBe(1); + } +} diff --git a/src/Marten/Events/EventGraph.cs b/src/Marten/Events/EventGraph.cs index 664f820c18..94b825282d 100644 --- a/src/Marten/Events/EventGraph.cs +++ b/src/Marten/Events/EventGraph.cs @@ -123,7 +123,13 @@ internal EventGraph(StoreOptions options) // there is no Id member if (idType == null) { - if (StreamIdentity == StreamIdentity.AsGuid) + // [BoundaryAggregate] SG emits TId=string (see jasperfx#324); match + // it here so the dispatcher lookup hits regardless of StreamIdentity. + if (typeof(TDoc).IsDefined(typeof(BoundaryAggregateAttribute), inherit: false)) + { + idType = typeof(string); + } + else if (StreamIdentity == StreamIdentity.AsGuid) { idType = typeof(Guid); }