Reputation: 2799
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?
Upvotes: 3
Views: 393
Reputation: 1666
You must perform the following steps:
Configure your IoC container as :
x.For(IUnitOfWork).Use(UnitOfWork)
Upvotes: 3