Skip to content

Comments

Dbcontextfactory#22

Merged
kr0ggg merged 3 commits intomainfrom
dbcontextfactory
Jan 9, 2026
Merged

Dbcontextfactory#22
kr0ggg merged 3 commits intomainfrom
dbcontextfactory

Conversation

@kr0ggg
Copy link
Collaborator

@kr0ggg kr0ggg commented Jan 9, 2026

No description provided.

Greg Cook added 3 commits January 8, 2026 11:24
- Created IIdentityProvider<TUserId> interface for automatic user ID retrieval
- Updated DbContextBase to accept and use IIdentityProvider with fallback priority:
  1. Manual WithUserId() override
  2. IIdentityProvider.GetCurrentUserId()
  3. Default null value
- Updated DbContextFactory to pass IIdentityProvider to DbContext instances
- Updated all sample and test contexts/factories to support new pattern
- Added SampleIdentityProvider implementation for demonstration
- Added Feature 13 to sample app demonstrating automatic user ID resolution
- Updated README.md with comprehensive IIdentityProvider documentation
- All 13 features now validated in CI/CD pipeline

This enables automatic user auditing without manual WithUserId() calls while
maintaining backward compatibility and allowing manual overrides when needed.
…ied constructors

- Added IdentityProvider<TUserId> concrete implementation with SetCurrentUserId(), GetCurrentUserId(), and ClearCurrentUserId() methods
- Added ServiceCollectionExtensions with AddIdentityProvider<TUserId>() and AddSingletonIdentityProvider<TUserId>() extension methods
- Registered IdentityProvider<TUserId> in ModuleStartup using open generic registration
- Simplified DbContextFactory<T, TUserId> to use single constructor with optional identityProvider parameter
- Simplified DbContextBase<TUserId> to use single constructor with optional identityProvider parameter
- Updated sample app to use built-in IdentityProvider instead of custom SampleIdentityProvider
- Updated SampleDbContext and SampleDbContextFactory to use simplified single-constructor pattern
- Added comprehensive documentation in README for built-in IdentityProvider usage
- All tests passing
- Changed IIdentityProvider.GetCurrentUserId() to return non-nullable TUserId
- Updated IdentityProvider, TestIdentityProvider, and SampleIdentityProvider implementations
- Modified DbContextBase.GetEffectiveUserId() to handle non-nullable return type
- Updated all test files to provide required IIdentityProvider parameter
- Enhanced README.md with comprehensive feature documentation
- Added detailed explanation of WithUserId() vs IIdentityProvider architecture
- Documented real-world use cases for operation-level user attribution
- All 61 tests passing
@kr0ggg kr0ggg merged commit b0e2ed6 into main Jan 9, 2026
3 checks passed
@kr0ggg kr0ggg deleted the dbcontextfactory branch January 9, 2026 00:57
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.

1 participant