@@ -34,7 +34,7 @@ public static IServiceCollection AddTriggeredDbContext<TContext>(this IServiceCo
3434 return serviceCollection ;
3535 }
3636
37- public static IServiceCollection AddTriggeredDbContextPool < TContext > ( this IServiceCollection serviceCollection , Action < DbContextOptionsBuilder > ? optionsAction = null , int poolSize = 128 )
37+ public static IServiceCollection AddTriggeredDbContextPool < TContext > ( this IServiceCollection serviceCollection , Action < DbContextOptionsBuilder > ? optionsAction = null , int poolSize = 1024 )
3838 where TContext : DbContext
3939 {
4040 serviceCollection . AddDbContextPool < TContext > ( options => {
@@ -55,6 +55,27 @@ public static IServiceCollection AddTriggeredDbContextPool<TContext>(this IServi
5555 return serviceCollection ;
5656 }
5757
58+ public static IServiceCollection AddTriggeredDbContextPool < TContext , TImplementation > ( this IServiceCollection serviceCollection , Action < DbContextOptionsBuilder > ? optionsAction = null , int poolSize = 1024 )
59+ where TContext : class where TImplementation : DbContext , TContext
60+ {
61+ serviceCollection . AddDbContextPool < TContext , TImplementation > ( options => {
62+ optionsAction ? . Invoke ( options ) ;
63+ options . UseTriggers ( ) ;
64+ } , poolSize ) ;
65+
66+ var serviceDescriptor = serviceCollection . FirstOrDefault ( x => x . ServiceType == typeof ( TContext ) ) ;
67+ if ( serviceDescriptor ? . ImplementationFactory != null )
68+ {
69+ serviceCollection . Replace ( ServiceDescriptor . Describe (
70+ serviceType : typeof ( TContext ) ,
71+ implementationFactory : serviceProvider => SetApplicationTriggerServiceProviderAccessor ( serviceDescriptor . ImplementationFactory ( serviceProvider ) , serviceProvider ) ,
72+ lifetime : ServiceLifetime . Transient
73+ ) ) ;
74+ }
75+
76+ return serviceCollection ;
77+ }
78+
5879 public static IServiceCollection AddTriggeredDbContextFactory < TContext > ( this IServiceCollection serviceCollection , Action < DbContextOptionsBuilder > ? optionsAction = null , ServiceLifetime lifetime = ServiceLifetime . Singleton )
5980 where TContext : DbContext
6081 {
0 commit comments