I am trying to reuse NopCommerce code to access data using Ninject. My question is: How can I introduce an undefined generic type for an object? I know that NopCommerce uses Autofac.
Description of my objects: I have a controller ( MyController) that contains a repository ( IRepository<T>). This repository is entered as EfRepository<T>using the ninject: command kernel.Bind(typeof(IRepository<>)).To(typeof(EfRepository<>)).
EfRepositoryhas a type IDbContextthat is common DbContext.
EfRepositorydoes not pass on to him the general type IDbContext, but still he is introduced to him. How is this done with Ninject?
the code;
public class MyController : Controller
{
private readonly IRepository<Account> _repository;
}
public class EfRepository<T> : IRepository<T> where T : BaseEntity
{
private IDbContext _context;
}
public interface IDbContext
{
IDbSet<T> Set<T>() where T : BaseEntity;
}
source
share