diff --git a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/Private.cs b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/Private.cs index ecd762823..c79a70b42 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/Private.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/Private.cs @@ -41,11 +41,11 @@ namespace SqlSugar { if (AsName == null) { - return queryable.Where(it => false).ToDataTable(); + return queryable.Where(it => false).Select("*").ToDataTable(); } else { - return queryable.AS(AsName).Where(it => false).ToDataTable(); + return queryable.AS(AsName).Where(it => false).Select("*").ToDataTable(); } } ); diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/Private.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/Private.cs index ecd762823..c79a70b42 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/Private.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/Private.cs @@ -41,11 +41,11 @@ namespace SqlSugar { if (AsName == null) { - return queryable.Where(it => false).ToDataTable(); + return queryable.Where(it => false).Select("*").ToDataTable(); } else { - return queryable.AS(AsName).Where(it => false).ToDataTable(); + return queryable.AS(AsName).Where(it => false).Select("*").ToDataTable(); } } ); diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleFastBuilder.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleFastBuilder.cs index 21895b4f1..ce273e8da 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleFastBuilder.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleFastBuilder.cs @@ -1,4 +1,5 @@ -using System; +using Oracle.ManagedDataAccess.Client; +using System; using System.Collections.Generic; using System.Data; using System.Text; @@ -8,9 +9,43 @@ namespace SqlSugar { public class OracleFastBuilder : FastBuilder, IFastBuilder { + private OracleBulkCopy GetBulkCopyInstance() + + { + if (this.Context.Ado.Connection.State == ConnectionState.Closed) + { + this.Context.Ado.Connection.Open(); + } + + OracleBulkCopy copy; + if (this.Context.Ado.Transaction == null) + { + copy = new OracleBulkCopy((OracleConnection)this.Context.Ado.Connection, Oracle.ManagedDataAccess.Client.OracleBulkCopyOptions.Default); + } + else + { + copy = new OracleBulkCopy((OracleConnection)this.Context.Ado.Connection, OracleBulkCopyOptions.UseInternalTransaction); + } + return copy; + + } public Task ExecuteBulkCopyAsync(DataTable dt) { - throw new NotImplementedException(); + OracleBulkCopy copy = GetBulkCopyInstance(); + try + { + copy.DestinationTableName = dt.TableName; + copy.WriteToServer(dt); + } + catch (Exception ex) + { + throw ex; + } + finally + { + CloseDb(); + } + return Task.FromResult(dt.Rows.Count); } } }