Browse Source

Update core

pull/10/head
sunkaixuna 3 years ago
parent
commit
18c799bc27
  1. 26
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/FastestProvider.cs
  2. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/Private.cs

26
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/FastestProvider.cs

@ -11,6 +11,7 @@ namespace SqlSugar
private SqlSugarProvider context;
private ISugarQueryable<T> queryable;
private EntityInfo entityInfo { get; set; }
public bool isLog;
public FastestProvider(SqlSugarProvider sqlSugarProvider)
{
this.context = sqlSugarProvider;
@ -78,6 +79,7 @@ namespace SqlSugar
#region Core
private async Task<int> _BulkUpdate(List<T> datas, string[] whereColumns, string[] updateColumns)
{
Begin(datas);
var isAuto = this.context.CurrentConnectionConfig.IsAutoCloseConnection;
this.context.CurrentConnectionConfig.IsAutoCloseConnection = false;
DataTable dt = ToDdateTable(datas);
@ -89,17 +91,41 @@ namespace SqlSugar
var result = await buider.UpdateByTempAsync(GetTableName(), dt.TableName, updateColumns, whereColumns);
this.context.DbMaintenance.DropTable(dt.TableName);
this.context.CurrentConnectionConfig.IsAutoCloseConnection = isAuto;
End(datas);
return result;
}
private async Task<int> _BulkCopy(List<T> datas)
{
Begin(datas);
DataTable dt = ToDdateTable(datas);
IFastBuilder buider =GetBuider();
buider.Context = context;
var result = await buider.ExecuteBulkCopyAsync(dt);
End(datas);
return result;
}
#endregion
#region AOP
private void End(List<T> datas)
{
this.context.Ado.IsEnableLogEvent = isLog;
if (this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted != null)
{
this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted($"End bulkcopy name:{entityInfo.DbTableName} ,count: {datas.Count},current time: {DateTime.Now}" , new SugarParameter[] { });
}
}
private void Begin(List<T> datas)
{
isLog = this.context.Ado.IsEnableLogEvent;
this.context.Ado.IsEnableLogEvent = false;
if (this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuting != null)
{
this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuting($"Begin bulkcopy name:{entityInfo.DbTableName} ,count: {datas.Count},current time: {DateTime.Now} ", new SugarParameter[] { });
}
}
#endregion
}
}

4
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/Private.cs

@ -20,7 +20,7 @@ namespace SqlSugar
case DbType.Sqlite:
break;
case DbType.Oracle:
break;
return new OracleFastBuilder();
case DbType.PostgreSQL:
return new PostgreSQLFastBuilder(this.entityInfo);
case DbType.Dm:
@ -32,7 +32,7 @@ namespace SqlSugar
default:
break;
}
throw new Exception(this.context.CurrentConnectionConfig.DbType + "开发中");
throw new Exception(this.context.CurrentConnectionConfig.DbType + "开发中...");
}
private DataTable ToDdateTable(List<T> datas)
{

Loading…
Cancel
Save