fix: Change SQLExecutor service registration to scoped
Updated the `AddSQLExecutor<T>` method in the `DIExtensions` class to register `ISQLExecutor<T>` as a scoped service instead of a singleton. This ensures that a new instance of `SQLExecutor<T>` is created for each request within the same scope, improving resource management and request isolation.
This commit is contained in:
parent
841da3c261
commit
7cffc3f7bc
@ -71,7 +71,7 @@ public static class DIExtensions
|
|||||||
|
|
||||||
public static IServiceCollection AddSQLExecutor<T>(this IServiceCollection services) where T : class
|
public static IServiceCollection AddSQLExecutor<T>(this IServiceCollection services) where T : class
|
||||||
{
|
{
|
||||||
services.AddSingleton<ISQLExecutor<T>, SQLExecutor<T>>();
|
services.AddScoped<ISQLExecutor<T>, SQLExecutor<T>>();
|
||||||
|
|
||||||
var interfaceType = typeof(ISQL<>);
|
var interfaceType = typeof(ISQL<>);
|
||||||
var targetGenericType = interfaceType.MakeGenericType(typeof(T));
|
var targetGenericType = interfaceType.MakeGenericType(typeof(T));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user