I've configured my IoC Container, Unity to resolve my IDbContext
an EntityFramwork DbContext
in the constructor of my unit of work.
I'm wondering if that is best practices or if I'm just getting in a future headaches of non disposed DbContext. This is an ASP.Net MVC application so there will be a lot of short-life containers. The lifetime of each container is per request
Any advice?
public class UnitOfWork : IUnitOfWork
{
private readonly IDbContext context;
public UnitOfWork(IDbContext context)
{
this.context = context;
}
}
public class SampleService : ISampleService
{
private readonly IUnitOfWork unitOfWork;
public SampleService(IUnitOfWork unitOfWork)
{
this.unitOfWork = unitOfWork;
}
}