mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update README.md
This commit is contained in:
parent
a7c2252d33
commit
d4893253f8
22
README.md
22
README.md
@ -294,29 +294,31 @@ var db = GetInstance();
|
|||||||
//1. no result
|
//1. no result
|
||||||
var result = db.UseTran(() =>
|
var result = db.UseTran(() =>
|
||||||
{
|
{
|
||||||
var beginCount = db.Queryable<Student>().Count();
|
var beginCount = db.Queryable<Student>().Count();
|
||||||
db.Ado.ExecuteCommand("delete student");
|
db.Ado.ExecuteCommand("delete student");
|
||||||
var endCount = db.Queryable<Student>().Count();
|
var endCount = db.Queryable<Student>().Count();
|
||||||
throw new Exception("error haha");
|
throw new Exception("error haha");
|
||||||
});
|
});
|
||||||
var count = db.Queryable<Student>().Count();
|
var count = db.Queryable<Student>().Count();
|
||||||
|
|
||||||
|
|
||||||
//2 has result
|
//2 has result
|
||||||
var result2 = db.UseTran<List<Student>>(() =>
|
var result2 = db.UseTran<List<Student>>(() =>
|
||||||
{
|
{
|
||||||
return db.Queryable<Student>().ToList();
|
return db.Queryable<Student>().ToList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//3 use try
|
//3 use try
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
db.Ado.BeginTran();
|
db.Ado.BeginTran();
|
||||||
|
xxxx
|
||||||
db.Ado.CommitTran();
|
db.Ado.CommitTran();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.Ado.RollbackTran();
|
db.Ado.RollbackTran();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user