IDatabase接口使用事务DbTransaction实例
IDatabase接口使用事务DbTransaction实例
DAL层代码参考:
C# Code:
public void TestTrans()
{
DbTransaction tran = _Database.TransBegin();
try
{
string SQL1 = "delete dt_Employee where 1=0";
_Database.ExecuteTrans(tran, SQL1);
string SQL2 = "update dt_Employee set EmpName='' where 1=0";
_Database.ExecuteTrans(tran, SQL2);
tran.Commit();
}
catch
{
tran.Rollback();
}
}