我的工作对象单元有 2 个依赖项,一个连接和一个事务。事务需要一个连接才能被绑定。不确定如何处理这种情况。
public class UnitOfWork : IUnitOfWork
{
public IDbConnection Connection { get; set; }
public IDbTransaction Transaction { get; set; }
public UnitOfWork(IDbConnection connection, IDbTransaction transaction)
{
this.Connection = connection;
// In order to create the transaction, it needs the passed in IDbConnection.
}
public void Commit()
{
}
public void Rollback()
{
}
}
我将如何处理这种情况?
Bind<IDbTransaction>().To<SqlTransaction>();