There is a unitofWork class with one constructor.
public UnitOfWork(DbContext context) { _context = context; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _context.Dispose(); } } _disposed = true; } ~UnitOfWork() { Dispose(false); } UnityConfig.cs has the following code.
container.RegisterType<DbContext, MyContext>(new PerResolveLifetimeManager()); container.RegisterType<IUnitOfWork, UnitOfWork>(); What tools can be used to do after I leave this constructor to dispose for the unitOfWork of each UnitOfWork (since it should be different)?
public HomeController(IUnitOfWork unitOfWork,IUnitOfWork u) { _unitOfWork = unitOfWork; u2 = u; var a = unitOfWork == u; }
using(unitOfWork)using(u){....}? - tym32167