I need help understanding unity and how IOC works.
I have it in my UnityContainer
var container = new UnityContainer(); // Register types container.RegisterType<IService, Service>(new HierarchicalLifetimeManager()); config.DependencyResolver = new UnityResolver(container);
Then in my web API controller, I understand that IService is introduced by Unity because it is a registered type.
public class MyController : ApiController { private IService _service;
My service interface
public interface IService { Item GetItemById(int id); }
My implementation service has its own constructor that accepts an EntityFramework DBContext object. (EF6)
public class Service : IService { private MyDbContext db;
source share