mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
-
This commit is contained in:
parent
0b5c9a1e91
commit
1f8b9535b4
@ -46,12 +46,12 @@ namespace SqlSugar
|
|||||||
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);
|
||||||
IFastBuilder buider = new SqlServerFastBuilder();
|
IFastBuilder buider = GetBuider();
|
||||||
buider.Context = context;
|
buider.Context = context;
|
||||||
await buider.CreateTempAsync<T>(dt);
|
await buider.CreateTempAsync<T>(dt);
|
||||||
await buider.ExecuteBulkCopyAsync(dt);
|
await buider.ExecuteBulkCopyAsync(dt);
|
||||||
//var queryTemp = this.context.Queryable<T>().AS(dt.TableName).ToList();//test
|
//var queryTemp = this.context.Queryable<T>().AS(dt.TableName).ToList();//test
|
||||||
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;
|
||||||
return result;
|
return result;
|
||||||
@ -63,10 +63,35 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
this.AsName = tableName;
|
this.AsName = tableName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Helper
|
#region Helper
|
||||||
|
private SqlServerFastBuilder GetBuider()
|
||||||
|
{
|
||||||
|
switch (this.context.CurrentConnectionConfig.DbType)
|
||||||
|
{
|
||||||
|
case DbType.MySql:
|
||||||
|
break;
|
||||||
|
case DbType.SqlServer:
|
||||||
|
return new SqlServerFastBuilder();
|
||||||
|
case DbType.Sqlite:
|
||||||
|
break;
|
||||||
|
case DbType.Oracle:
|
||||||
|
break;
|
||||||
|
case DbType.PostgreSQL:
|
||||||
|
break;
|
||||||
|
case DbType.Dm:
|
||||||
|
break;
|
||||||
|
case DbType.Kdbndp:
|
||||||
|
break;
|
||||||
|
case DbType.Oscar:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
throw new Exception(this.context.CurrentConnectionConfig.DbType + "开发中");
|
||||||
|
}
|
||||||
private DataTable ToDdateTable(List<T> datas)
|
private DataTable ToDdateTable(List<T> datas)
|
||||||
{
|
{
|
||||||
DataTable tempDataTable = ReflectionInoCore<DataTable>.GetInstance().GetOrCreate("BulkCopyAsync" + typeof(T).FullName, () => queryable.Where(it => false).ToDataTable());
|
DataTable tempDataTable = ReflectionInoCore<DataTable>.GetInstance().GetOrCreate("BulkCopyAsync" + typeof(T).FullName, () => queryable.Where(it => false).ToDataTable());
|
||||||
|
Loading…
Reference in New Issue
Block a user