Fix avvio API con scope corretto servizi DB
This commit is contained in:
+14
-9
@@ -155,18 +155,12 @@ builder.Services.AddDbContext<DataLayerContext>(options =>
|
||||
.LogTo(_ => { }); // disabilita EF logging;
|
||||
});
|
||||
|
||||
//builder.Services.AddSingleton<DataLayerServices>();
|
||||
builder.Services.AddSingleton<DataLayerServices>();
|
||||
// altri servizi!
|
||||
builder.Services.AddSingleton<ImageCacheService>();
|
||||
builder.Services.AddSingleton<ExternalMessageProcessor>();
|
||||
builder.Services.AddHostedService<RedisSubscriberService>();
|
||||
builder.Services.AddSingleton<ConfigDataService>();
|
||||
builder.Services.AddSingleton<ProdService>();
|
||||
// servizi Scoped (usano DB)
|
||||
|
||||
//builder.Services.AddSingleton<DataLayerServices>();
|
||||
builder.Services.AddScoped<DataLayerServices>();
|
||||
// Repository con interfaccia
|
||||
builder.Services.AddScoped<IGenClassRepository, GenClassRepository>();
|
||||
|
||||
// Servizi dati con interfaccia
|
||||
builder.Services.AddScoped<IGenClassService, GenClassService>();
|
||||
|
||||
@@ -188,6 +182,17 @@ builder.Services.Scan(scan => scan
|
||||
);
|
||||
#endif
|
||||
|
||||
// servizi Singleton (no DB)
|
||||
builder.Services.AddSingleton<ImageCacheService>();
|
||||
builder.Services.AddSingleton<ConfigDataService>();
|
||||
builder.Services.AddSingleton<ProdService>();
|
||||
|
||||
// servizi con dipendenze" ma Scoped
|
||||
builder.Services.AddScoped<ExternalMessageProcessor>();
|
||||
|
||||
// servizi hosted usano scope factory
|
||||
builder.Services.AddHostedService<RedisSubscriberService>();
|
||||
|
||||
// init servizio gestone ReqIndex
|
||||
string cleanupDayTTL = configuration.GetValue<string>("ServerConf:CleanupDayTTL") ?? "360";
|
||||
string rBaseKey = configuration.GetValue<string>("ServerConf:RedisBaseKey") ?? "Lux";
|
||||
|
||||
Reference in New Issue
Block a user