I am new to Repository and DI and trying to implement in my MVC 5 project.
I implemented Constructor Injection where in my controller has a constructor like this:
IBook _ibook;
public Test(IBook ibook)
{
_ibook = ibook;
}
Without any DI framework, it throws an error: There is no empty constructor.
To avoid this, I added one more constructor as below:
public Test ():(new Book())
{
}
Since I am new to DI, I don't want to risk my project by using DI framework which can later throw some error that I may not be able to resolve.
I want to know what issues I might encounter if I am not using DI Framework.
In case it is recommended, which DI Framework is good for beginners? I have seen few videos of NInject and Unity.
Aucun commentaire:
Enregistrer un commentaire