3
Ninject似乎有問題解決以下幾個:通用綁定在Ninject沒有默認構造
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;
}
}
當有必要做一些特別的東西,我做的:
public interface IMyEntityRepository : IRepository<MyEntity>
{
int GetSomeStuffForAnObject();
}
這一工程很好,但綁定不起作用,如果我只使用默認Repository<T>
。
Bind(typeof(IRepository <>))。(typeof(Repository <>)); – bhaydin
請使用標記行下的_「edit」_鏈接來編輯您的問題並放入您的評論代碼(我不知道該放哪裏) –