Skip to content

Add WithAlternateSession to SliceGroup enrichment chain#195

Merged
jeremydmiller merged 2 commits intoJasperFx:mainfrom
erdtsieck:feature/ancillary-store-enrichment-marten-4300
Apr 28, 2026
Merged

Add WithAlternateSession to SliceGroup enrichment chain#195
jeremydmiller merged 2 commits intoJasperFx:mainfrom
erdtsieck:feature/ancillary-store-enrichment-marten-4300

Conversation

@erdtsieck
Copy link
Copy Markdown
Contributor

@erdtsieck erdtsieck commented Apr 28, 2026

Summary

Enables declarative enrichment from ancillary stores by extending the EnrichWith<T>() fluent chain in SliceGroup.

  • Adds IServiceProvider? Services { get; } default member to IStorageOperations so Marten extensions can resolve DI services from the session
  • Threads a disposeAfterUse flag through EntityStepEventStepIdentityStep; the alternate session is disposed in a finally block after enrichment completes
  • Adds EntityStep<TEntity>.WithAlternateSession(IStorageOperations) — redirects enrichment loading to a different session with automatic dispose-after-use semantics; the primary store session is never disposed
  • Caching is fully preserved: findCache<TEntityId, TEntity>() is still called first; the alternate session is only hit on cache misses
  • Adds WithAlternateSessionTests (5 tests) covering: alternate storage used, session disposed, session disposed on no-match, primary not disposed, AddReferences via alternate

Related

Marten feature request: JasperFx/marten#4300

… 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.
@jeremydmiller jeremydmiller merged commit b89fd91 into JasperFx:main Apr 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants