Reputation: 41
Ninject seems to be having issues resolving the following:
public interface IRepository<TEntity> : IDisposable where TEntity : class,IEntity
{
}
public class Repository<TEntity> : IRepository<TEntity> where TEntity : class,IEntity
{
protected IDbContext _context;
public Repository(IDbContext context)
{
_context = context;
}
}
When there is a need to do something special, I do:
public interface IMyEntityRepository : IRepository<MyEntity>
{
int GetSomeStuffForAnObject();
}
That works great, but binding doesn't work if I am just using the default Repository<T>
.
Upvotes: 3
Views: 237
Reputation: 41
Ok, I must have missed something earlier.
Bind(typeof(IRepository<>)).To(typeof(Repository<>));
Seems to work.
Upvotes: 1