调用Commit时(为了实现IEnlistmentNotification)我可以抛出一个异常来表示我希望事务回滚吗?
答案 0 :(得分:0)
您应该致电Transaction.Rollback(Exception ex):
public void Commit(Enlistment enlistment)
{
Transaction currentTx = Transaction.Current;
if (currentTx != null)
{
currentTx.RollBack(new Exception("I give up!");
}
}