问一个关于TransactionScope的问题
public void InsertTest()
{
InsertStudent();
using (TransactionScope tc = new TransactionScope(TransactionScopeOption.Required))
{
InsertStudent(); //插入学生情况
InsertTeacher(); //故意让它出错
tc.Complete();
}
}
我对这个事务没有搞清楚,不是说任何都要回滚吗?为什么我的InsertStudent()语句一直能够插入吗?如果InsertTeacher()这个出错,前面也应该插入不了数据啊?要不我拿这个事务来何用?