Add WithAlternateSession to SliceGroup enrichment chain#195
Merged
jeremydmiller merged 2 commits intoJasperFx:mainfrom Apr 28, 2026
Merged
Conversation
… store support (marten#4300)
- Add IServiceProvider? Services { get; } default member to IStorageOperations
- Add disposeAfterUse flag through EntityStep/EventStep/IdentityStep chain
- Add WithAlternateSession(IStorageOperations) on EntityStep — swaps session with dispose-after-use semantics
- IdentityStep.FetchEntitiesAsync disposes session in finally block when disposeAfterUse=true
- Add WithAlternateSessionTests covering: alternate storage used, session disposed, no-match dispose, primary not disposed, AddReferences via alternate
…e enrichment Resolves a Func<TStore, IStorageOperations> factory and the store itself from the session's ServiceProvider, then delegates to WithAlternateSession. This allows the call site to specify only the store type (.UsingStore<IProductStore>()) without phantom types or constructor injection.
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.
Summary
Enables declarative enrichment from ancillary stores by extending the
EnrichWith<T>()fluent chain inSliceGroup.IServiceProvider? Services { get; }default member toIStorageOperationsso Marten extensions can resolve DI services from the sessiondisposeAfterUseflag throughEntityStep→EventStep→IdentityStep; the alternate session is disposed in afinallyblock after enrichment completesEntityStep<TEntity>.WithAlternateSession(IStorageOperations)— redirects enrichment loading to a different session with automatic dispose-after-use semantics; the primary store session is never disposedfindCache<TEntityId, TEntity>()is still called first; the alternate session is only hit on cache missesWithAlternateSessionTests(5 tests) covering: alternate storage used, session disposed, session disposed on no-match, primary not disposed,AddReferencesvia alternateRelated
Marten feature request: JasperFx/marten#4300