I'm using StructureMap in ASP .Net MVC 4 and I have got the following Interface and implemented class in my project infrastructure :
public interface IUnitOfWork
{
void Commit();
}
public class UnitOfWork : IUnitOfWork
{
public void Commit()
{
// Track all changes in database
}
}
My HomeController is used the IUnitOfWork interface as constructor parameter :
public class HomeController
{
IUnitOfwork unitOfWork;
public HomeController(IUnitOfwork unitOfWork)
{
this.unitOfWork = unitOfWork;
}
}
How can I inject IUniOfWork interface to overloaded HomeController class as parameter?
You must perform the following steps:
Configure your IoC container as :
x.For(IUnitOfWork).Use(UnitOfWork)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With