Update SqlSguarTransaction

This commit is contained in:
sunkaixuna
2021-09-01 00:31:50 +08:00
parent 12ebd0e893
commit d8d75a2b45
2 changed files with 17 additions and 1 deletions

View File

@@ -27,7 +27,15 @@ namespace OrmTest
private static void ConfiQuery() private static void ConfiQuery()
{ {
var db = GetInstance(); var db = GetInstance();
List<DataDictionary> datas = new List<DataDictionary>(); using (var tran = db.UseTran())
{
tran.CommitTran();
}
List<DataDictionary> datas = new List<DataDictionary>();
datas.Add(new DataDictionary() { Code="1", Name="男",Type="sex" }); datas.Add(new DataDictionary() { Code="1", Name="男",Type="sex" });
datas.Add(new DataDictionary() { Code = "2", Name = "女", Type = "sex" }); datas.Add(new DataDictionary() { Code = "2", Name = "女", Type = "sex" });
datas.Add(new DataDictionary() { Code = "1", Name = "南通市", Type = "city" }); datas.Add(new DataDictionary() { Code = "1", Name = "南通市", Type = "city" });

View File

@@ -15,6 +15,14 @@ namespace SqlSugar
context = client; context = client;
context.BeginTran(); context.BeginTran();
} }
public void CommitTran()
{
context.CommitTran();
}
public void RollbackTran()
{
context.RollbackTran();
}
public void Dispose() public void Dispose()
{ {
context.RollbackTran(); context.RollbackTran();