I have a unit of work class, which contains an ExpressionRepository. I want to replace it with an interface (IExpressionRepository) and bind it to ExpressionRepository with Ninject, but here's the problem: My ExpressionRepository expects a DbContext as a constructor parameter, but you can't define a constructor in an interface as far as I know, so I can't call this constructor without using the concrete implementation.
Here's the code as it stands now, without using an interface:
private DbContext _dbContext;
private ExpressionRepository _expressionRepository;
public UnitOfWork(DbContext dbContext)
{
_dbContext = dbContext;
}
public ExpressionRepository ExpressionRepository
{
get { return _expressionRepository ?? (_expressionRepository = new ExpressionRepository(_dbContext)); }
}
My best guess is to add a method like 'void setDataSource(Object dataSource)' to my interface, but is there a better way?