Browse Source

add IsolationLevel for BeginTranAsync

pull/31/head
Lucas 2 years ago
parent
commit
4ff15bd4ba
  1. 6
      Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Interface/IAdo.cs
  3. 9
      Src/Asp.Net/SqlSugar/OnlyNet/AsyncHelper.cs
  4. 6
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs

6
Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs

@ -223,6 +223,12 @@ namespace SqlSugar
if (this.Transaction == null)
this.Transaction = this.Connection.BeginTransaction(iso);
}
public virtual async Task BeginTranAsync(IsolationLevel iso)
{
await CheckConnectionAsync();
if (this.Transaction == null)
this.Transaction =await (this.Connection as DbConnection).BeginTransactionAsync(iso);
}
public virtual void RollbackTran()
{
if (this.Transaction != null)

1
Src/Asp.Net/SqlSugar/Interface/IAdo.cs

@ -172,6 +172,7 @@ namespace SqlSugar
void BeginTran();
Task BeginTranAsync();
Task BeginTranAsync(IsolationLevel iso);
void BeginTran(IsolationLevel iso);
void BeginTran(string transactionName);
void BeginTran(IsolationLevel iso, string transactionName);

9
Src/Asp.Net/SqlSugar/OnlyNet/AsyncHelper.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
@ -15,6 +16,14 @@ namespace SqlSugar
//.net frame work no BeginTransactionAsync
return db.BeginTransaction();
}
public static async Task<DbTransaction> BeginTransactionAsync(this DbConnection db, IsolationLevel iso)
{
await Task.Delay(0);
//.net frame work no BeginTransactionAsync
return db.BeginTransaction(iso);
}
public static async Task CloseAsync(this DbConnection db)
{
await Task.Delay(0);

6
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -929,6 +929,12 @@ namespace SqlSugar
_IsAllTran = true;
await AllClientEachAsync(async it => await it.Ado.BeginTranAsync());
}
public async Task BeginTranAsync(IsolationLevel iso)
{
_IsAllTran = true;
await AllClientEachAsync(async it => await it.Ado.BeginTranAsync(iso));
}
public void CommitTran()
{

Loading…
Cancel
Save