Update db.ado.OpenAlways

This commit is contained in:
sunkaixuan 2022-03-13 12:16:03 +08:00
parent 48d093a191
commit 4ec5fbd5bb
4 changed files with 30 additions and 2 deletions

View File

@ -77,10 +77,15 @@ namespace SqlSugar
{
CheckConnection();
}
public virtual void OpenAlways()
public SugarConnection OpenAlways()
{
SugarConnection result = new SugarConnection();
result.IsAutoClose = this.Context.CurrentConnectionConfig.IsAutoCloseConnection;
result.conn = this.Connection;
result.Context = this.Context;
this.Context.CurrentConnectionConfig.IsAutoCloseConnection = false;
this.Open();
return result;
}
public virtual void Close()
{

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class SugarConnection:IDisposable
{
public IDbConnection conn { get; set; }
public bool IsAutoClose { get; set; }
public ISqlSugarClient Context { get; set; }
public void Dispose()
{
conn.Close();
this.Context.CurrentConnectionConfig.IsAutoCloseConnection = IsAutoClose;
}
}
}

View File

@ -163,7 +163,7 @@ namespace SqlSugar
void Dispose();
void Close();
void Open();
void OpenAlways();
SugarConnection OpenAlways();
void CheckConnection();
void BeginTran();

View File

@ -97,6 +97,7 @@
<Compile Include="Abstract\SaveableProvider\StorageableDataTable.cs" />
<Compile Include="Abstract\SugarProvider\SqlSugarCoreProvider.cs" />
<Compile Include="Entities\JoinMapper.cs" />
<Compile Include="Entities\SugarConnection.cs" />
<Compile Include="ExpressionsToSql\Subquery\SubTemplate.cs" />
<Compile Include="ExpressionsToSql\Subquery\SubqueryableN.cs" />
<Compile Include="Infrastructure\StaticConfig.cs" />