mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-18 05:59:34 +08:00
Db.Fastest support aop
This commit is contained in:
parent
1f78eaf008
commit
7ba54710c3
@ -11,6 +11,7 @@ namespace SqlSugar
|
|||||||
private SqlSugarProvider context;
|
private SqlSugarProvider context;
|
||||||
private ISugarQueryable<T> queryable;
|
private ISugarQueryable<T> queryable;
|
||||||
private EntityInfo entityInfo { get; set; }
|
private EntityInfo entityInfo { get; set; }
|
||||||
|
public bool isLog;
|
||||||
public FastestProvider(SqlSugarProvider sqlSugarProvider)
|
public FastestProvider(SqlSugarProvider sqlSugarProvider)
|
||||||
{
|
{
|
||||||
this.context = sqlSugarProvider;
|
this.context = sqlSugarProvider;
|
||||||
@ -78,6 +79,7 @@ namespace SqlSugar
|
|||||||
#region Core
|
#region Core
|
||||||
private async Task<int> _BulkUpdate(List<T> datas, string[] whereColumns, string[] updateColumns)
|
private async Task<int> _BulkUpdate(List<T> datas, string[] whereColumns, string[] updateColumns)
|
||||||
{
|
{
|
||||||
|
Begin();
|
||||||
var isAuto = this.context.CurrentConnectionConfig.IsAutoCloseConnection;
|
var isAuto = this.context.CurrentConnectionConfig.IsAutoCloseConnection;
|
||||||
this.context.CurrentConnectionConfig.IsAutoCloseConnection = false;
|
this.context.CurrentConnectionConfig.IsAutoCloseConnection = false;
|
||||||
DataTable dt = ToDdateTable(datas);
|
DataTable dt = ToDdateTable(datas);
|
||||||
@ -89,17 +91,41 @@ namespace SqlSugar
|
|||||||
var result = await buider.UpdateByTempAsync(GetTableName(), dt.TableName, updateColumns, whereColumns);
|
var result = await buider.UpdateByTempAsync(GetTableName(), dt.TableName, updateColumns, whereColumns);
|
||||||
this.context.DbMaintenance.DropTable(dt.TableName);
|
this.context.DbMaintenance.DropTable(dt.TableName);
|
||||||
this.context.CurrentConnectionConfig.IsAutoCloseConnection = isAuto;
|
this.context.CurrentConnectionConfig.IsAutoCloseConnection = isAuto;
|
||||||
|
End();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private async Task<int> _BulkCopy(List<T> datas)
|
private async Task<int> _BulkCopy(List<T> datas)
|
||||||
{
|
{
|
||||||
|
Begin();
|
||||||
DataTable dt = ToDdateTable(datas);
|
DataTable dt = ToDdateTable(datas);
|
||||||
IFastBuilder buider =GetBuider();
|
IFastBuilder buider =GetBuider();
|
||||||
buider.Context = context;
|
buider.Context = context;
|
||||||
var result = await buider.ExecuteBulkCopyAsync(dt);
|
var result = await buider.ExecuteBulkCopyAsync(dt);
|
||||||
|
End();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region AOP
|
||||||
|
private void End()
|
||||||
|
{
|
||||||
|
this.context.Ado.IsEnableLogEvent = isLog;
|
||||||
|
if (this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted != null)
|
||||||
|
{
|
||||||
|
this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted("Begin bulkcopy "+ entityInfo.DbTableName, new SugarParameter[] { });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Begin()
|
||||||
|
{
|
||||||
|
isLog = this.context.Ado.IsEnableLogEvent;
|
||||||
|
this.context.Ado.IsEnableLogEvent = false;
|
||||||
|
if (this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuting != null)
|
||||||
|
{
|
||||||
|
this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuting("End bulkcopy " + entityInfo.DbTableName, new SugarParameter[] { });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user