mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
-
This commit is contained in:
parent
93a959b4a7
commit
0e26b51beb
@ -29,16 +29,31 @@ namespace OrmTest.Demo
|
||||
{
|
||||
var db = GetInstance();
|
||||
|
||||
//1. no result
|
||||
var result=db.UseTran(() =>
|
||||
{
|
||||
var count= db.Ado.ExecuteCommand("delete student");
|
||||
throw new Exception("error haha");
|
||||
});
|
||||
|
||||
//2 has result
|
||||
var result2 = db.UseTran<List<Student>>(() =>
|
||||
{
|
||||
return db.Queryable<Student>().ToList();
|
||||
});
|
||||
|
||||
//3 use try
|
||||
try
|
||||
{
|
||||
db.Ado.BeginTran();
|
||||
|
||||
db.Ado.CommitTran();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
db.Ado.RollbackTran();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Group()
|
||||
|
Loading…
Reference in New Issue
Block a user