Rezi
dependency injection problem. hangfire jobs.
so i have this problem.
whenever i'm trying to inject dbcontext in my service layer for my hangfire job, i get error that db context is already being disposed.
but if i do by using IserviceScopeFactory. it's working. (found this solution in chatgpt).
but i don't rly like this.
how can i configure hangfire so it doesn't dispose dbcontext prematurely?
any ideas?
public class JobService : IJobService
{
private readonly IServiceScopeFactory _serviceScopeFactory;
public JobService(IServiceScopeFactory serviceScopeFactory)
{
_serviceScopeFactory = serviceScopeFactory;
}
public async void UpdateJobStatus()
{
using var scope = _serviceScopeFactory.CreateScope();
var jobRepository = scope.ServiceProvider.GetRequiredService<IJobRepository>();
}
}
3 replies
quick question. clean architecture
hey guys, quick question here.
i want to make a custom error txt.
for example: data not found. data is deleted.
stuff like that.
i than want to throw that from application layer.
where would i store this error? in domain layer as like general error or in application layer?
5 replies