I have a IRepository that I have implemented in Repository and I extended Repository for specific type as UsersRepository I need to bind all types using the generic binding for Ninject however when requesting instance for IRepository I need to get UsersRepository instead of Repository.
Bind<IDbContext>().To<SMSDataContext>()
.WithConstructorArgument("connectionStringName", "dbcsname");
Here I am binding the generic repository:
Bind(typeof(IRepository<>)).To(typeof(Repository<>))
.WithConstructorArgument("dbContext",new SMSDataContext("dbcsname"));
Here I am trying to bind a specific instance:
Bind<IRepository<Setting>>().ToConstant(settingsRepository);
Tried different approaches with ".ToConstant" and with only ".To" also tried to bind to concrete implementation like follows:
UsersRepository usersRepository = new UsersRepository(new SMSDataContext("SMSDB"));
Bind<IRepository<Setting>>().To<SettingsRepository>().WithConstructorArgument("dbContext", new SMSDataContext("dbscname")); ;
Please advise.