好吧,我觉得自己像个白痴。我已经阅读了文档,但仍然无法与 Ninject 一起使用。
public class ContextAdapter:IDbSetProvider
{
private readonly IContextFactory _contextFactory;
#region Implementation of IDbSetProvider
public ContextAdapter(IContextFactory contextFactory)
{
this._contextFactory = contextFactory;
}
public IDbSet<TEntity> CreateDBSet<TEntity>() where TEntity : class
{
var context = _contextFactory.Create();
return context.Set<TEntity>();
}
#endregion
}
如您所见,我需要为上面的类注入构造函数。好吧,事情进展得不太顺利。帮助!!在我回到编写 perl 代码之前。开玩笑!!哈哈
想的人?