I'm trying to register to implementations of same interface using named instances
kernel.Bind<IRepository>().To<CachedRepository>().InSingletonScope();
kernel.Bind<IRepository>().To<DbRepository>().InSingletonScope().Named("db");
the idea, is that if I not specify the name then the CachedRepository gets created, if I need a DB oriented one then I'd use the Named attribute, but this miserable fails when a simple object would get created
public class TripManagerController : Controller
{
[Inject]
public IRepository Repository { get; set; } // default Cached repo must be created
public TripManagerController()
{
ViewBag.LogedEmail = "test@test.com";
}
}
the error is
Error activating IRepository More than one matching bindings are available. Activation path: 2) Injection of dependency IRepository into parameter repository of constructor of type TripManagerController 1) Request for TripManagerController
Suggestions: 1) Ensure that you have defined a binding for IRepository only once.
Is there a way to achieve what I want without creating a new interface for BD oriented repositories? Thx