I have a repository RepositoryDepartment which takes DbContext (i.e. AdventureworksDB) as a constructor parameter.
public class RepositoryDepartment : Repository<Department>, IRepositoryDepartment
{
AdventureWorksDB _ctx;
public RepositoryDepartment(AdventureWorksDB dataContext)
: base(dataContext)
{
_ctx = dataContext;
}
I have mapped the public interface IRepositoryDepartment : IRepository<Department> to RepositoryDepartment using Unity DI.
So when I resolve the IRepositoryDepartment interface like this:
Container.Resolve<IRepositoryDepartment>()
I get a fully functional RepositoryDepartment Object. But the question here is: How does the AdventureworksDB constructor parameter get instantiated, as I didn't register the type nowhere??? The base class only gets the object, it has no instantiation logic! Can someone explain the magic that happens here!?