Browse Source

add IsolationLevel for BeginTranAsync

pull/31/head
Lucas 2 years ago
parent
commit
f128c718cc
  1. 8
      Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
  2. 1
      Src/Asp.NetCore2/SqlSugar/Interface/IAdo.cs
  3. 12
      Src/Asp.NetCore2/SqlSugar/SqlSugarClient.cs

8
Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs

@ -217,6 +217,14 @@ namespace SqlSugar
if (this.Transaction == null)
this.Transaction =await (this.Connection as DbConnection).BeginTransactionAsync();
}
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 BeginTran(IsolationLevel iso)
{
CheckConnection();

1
Src/Asp.NetCore2/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);

12
Src/Asp.NetCore2/SqlSugar/SqlSugarClient.cs

@ -923,12 +923,24 @@ namespace SqlSugar
_IsAllTran = true;
AllClientEach(it => it.Ado.BeginTran());
}
public void BeginTran(IsolationLevel iso)
{
_IsAllTran = true;
AllClientEach(it => it.Ado.BeginTran(iso));
}
public async Task BeginTranAsync()
{
_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