I'm using Unity to instantiate my MenuRepository instance. I'm getting the following error when trying to do so..
The type list`1 has multiple constructors of length 1. unable to disambiguate.
I've tried the following registration, but with no luck..
container.RegisterType<IMenuRepository, MenuRepository>(
new PerThreadLifetimeManager(),
new InjectionConstructor(typeof(IMonopolyEntitiesDbContext),
typeof(List<MenuLink>)));
Here's my registration
container.RegisterType<MenuLink>();
container.RegisterType <List<MenuLink>>();
container.RegisterType<IMonopolyEntitiesDbContext, MonopolyEntities>(
new PerThreadLifetimeManager());
container.RegisterType<IMenuRepository, MenuRepository>(
new PerThreadLifetimeManager(),
new InjectionConstructor(typeof(IMonopolyEntitiesDbContext), typeof(List<MenuLink>)));
MenuRepository
public class MenuRepository : IMenuRepository
{
IMonopolyEntitiesDbContext _dbContext;
List<MenuLink> _allsubMenus;
public MenuRepository(IMonopolyEntitiesDbContext context, List<MenuLink> allsubMenus)
{
_dbContext = context;
_allsubMenus = allsubMenus;
}
}
List<T>(sequence)
orList<T>(length)
. – neontapirList<MenuLink>
contain? Is this a fixed list ofMenuItem
objects that doesn't change for the duration of the application? Or is this data that is requeried from the database on each request? Could you elaborate? – StevenList<MenuLink>
, it allows me to post my answer and help you with your problem. – Steven