#4284 Support DI-backed composite projections#4285
Merged
jeremydmiller merged 1 commit intoJasperFx:masterfrom Apr 26, 2026
Merged
#4284 Support DI-backed composite projections#4285jeremydmiller merged 1 commit intoJasperFx:masterfrom
jeremydmiller merged 1 commit intoJasperFx:masterfrom
Conversation
Add support for registering composite projections that require application services (DI). - Introduce CompositeProjection.AddProjectionWithServices<T> to register projections resolved from IServiceProvider, honoring ServiceLifetime (Transient treated as Scoped, Singleton uses a single instance). - Implement internal plumbing: CompositeProjection now accepts an IServiceProvider and propagates it to projections via ICompositeProjectionServiceSource; add CompositeProjectionWithServicesSource, CompositeScopedIProjectionSource, CompositeScopedIProjectionExecution, and ProjectionActivatingServiceProvider/Scope to create/execute projections within scoped service scopes. - Wire service provider attachment through ProjectionOptions.AttachServiceProvider and call it when building stores (MartenServiceCollectionExtensions and SecondaryStoreConfig) so projections registered in AddMarten can resolve DI services. - Add an integration test (Feature_4284_composite_projection_with_services) that verifies scoped services are available to composite projections and that projections produce expected documents. This enables composite projections to depend on scoped/singleton services from the host DI container when registered through AddMarten.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for registering composite projections that require application services (DI).
This enables composite projections to depend on scoped/singleton services from the host DI container when registered through AddMarten.
Fixes #4284