From d8d75a2b45be1787e98dc94ba4bc010a35922d23 Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Wed, 1 Sep 2021 00:31:50 +0800 Subject: [PATCH] Update SqlSguarTransaction --- Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs | 10 +++++++++- Src/Asp.Net/SqlSugar/Entities/SqlSguarTransaction.cs | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs b/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs index 2fa2897c7..d74b239da 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs @@ -27,7 +27,15 @@ namespace OrmTest private static void ConfiQuery() { var db = GetInstance(); - List datas = new List(); + using (var tran = db.UseTran()) + { + + + tran.CommitTran(); + } + + + List datas = new List(); datas.Add(new DataDictionary() { Code="1", Name="男",Type="sex" }); datas.Add(new DataDictionary() { Code = "2", Name = "女", Type = "sex" }); datas.Add(new DataDictionary() { Code = "1", Name = "南通市", Type = "city" }); diff --git a/Src/Asp.Net/SqlSugar/Entities/SqlSguarTransaction.cs b/Src/Asp.Net/SqlSugar/Entities/SqlSguarTransaction.cs index ab756bb96..6177b27d7 100644 --- a/Src/Asp.Net/SqlSugar/Entities/SqlSguarTransaction.cs +++ b/Src/Asp.Net/SqlSugar/Entities/SqlSguarTransaction.cs @@ -15,6 +15,14 @@ namespace SqlSugar context = client; context.BeginTran(); } + public void CommitTran() + { + context.CommitTran(); + } + public void RollbackTran() + { + context.RollbackTran(); + } public void Dispose() { context.RollbackTran();