mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 04:23:47 +08:00
Update db.ado.OpenAlways
This commit is contained in:
@@ -77,10 +77,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
CheckConnection();
|
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.Context.CurrentConnectionConfig.IsAutoCloseConnection = false;
|
||||||
this.Open();
|
this.Open();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
public virtual void Close()
|
public virtual void Close()
|
||||||
{
|
{
|
||||||
|
22
Src/Asp.Net/SqlSugar/Entities/SugarConnection.cs
Normal file
22
Src/Asp.Net/SqlSugar/Entities/SugarConnection.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -163,7 +163,7 @@ namespace SqlSugar
|
|||||||
void Dispose();
|
void Dispose();
|
||||||
void Close();
|
void Close();
|
||||||
void Open();
|
void Open();
|
||||||
void OpenAlways();
|
SugarConnection OpenAlways();
|
||||||
void CheckConnection();
|
void CheckConnection();
|
||||||
|
|
||||||
void BeginTran();
|
void BeginTran();
|
||||||
|
@@ -97,6 +97,7 @@
|
|||||||
<Compile Include="Abstract\SaveableProvider\StorageableDataTable.cs" />
|
<Compile Include="Abstract\SaveableProvider\StorageableDataTable.cs" />
|
||||||
<Compile Include="Abstract\SugarProvider\SqlSugarCoreProvider.cs" />
|
<Compile Include="Abstract\SugarProvider\SqlSugarCoreProvider.cs" />
|
||||||
<Compile Include="Entities\JoinMapper.cs" />
|
<Compile Include="Entities\JoinMapper.cs" />
|
||||||
|
<Compile Include="Entities\SugarConnection.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\SubTemplate.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\SubTemplate.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\SubqueryableN.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\SubqueryableN.cs" />
|
||||||
<Compile Include="Infrastructure\StaticConfig.cs" />
|
<Compile Include="Infrastructure\StaticConfig.cs" />
|
||||||
|
Reference in New Issue
Block a user