TransactionScope TransactionABC = new TransactionScope();
try
{
context.Connection.Open();
{
context.ExecuteCommand("insert into test (test) values (1)")
context.SubmitChanges();
context.ExecuteCommand("savepoint test");
context.ExecuteCommand("insert into test (test) values (2)")
context.SubmitChanges();
context.ExecuteCommand("rollback to test");
}
TransactionABC.Complete();
TransactionABC.Dispose();
}
catch (Exception ec)
{
MessageBox.Show(" ", ec.Message);
}
finally
{
context.Connection.Close();
}
它有效,但仅适用于 ExecuteCommand。我想使用一个函数,因为我看不到保存点中发生了什么!