mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-17 21:49:33 +08:00
Update dm bulkcopy
This commit is contained in:
parent
9fcd783640
commit
a9461c4aef
@ -5,7 +5,7 @@ using System.Data.SqlClient;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Dm;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class DmBlukCopy
|
public class DmBlukCopy
|
||||||
@ -25,7 +25,7 @@ namespace SqlSugar
|
|||||||
return WriteToServer();
|
return WriteToServer();
|
||||||
}
|
}
|
||||||
DataTable dt = GetCopyData();
|
DataTable dt = GetCopyData();
|
||||||
SqlBulkCopy bulkCopy = GetBulkCopyInstance();
|
DmBulkCopy bulkCopy = GetBulkCopyInstance();
|
||||||
bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
|
bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -49,11 +49,12 @@ namespace SqlSugar
|
|||||||
return WriteToServer();
|
return WriteToServer();
|
||||||
}
|
}
|
||||||
DataTable dt=GetCopyData();
|
DataTable dt=GetCopyData();
|
||||||
SqlBulkCopy bulkCopy = GetBulkCopyInstance();
|
DmBulkCopy bulkCopy = GetBulkCopyInstance();
|
||||||
bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
|
bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await bulkCopy.WriteToServerAsync(dt);
|
bulkCopy.WriteToServer(dt);
|
||||||
|
await Task.Delay(0);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -71,7 +72,7 @@ namespace SqlSugar
|
|||||||
return 0;
|
return 0;
|
||||||
Check.Exception(dt.TableName == "Table", "dt.TableName can't be null ");
|
Check.Exception(dt.TableName == "Table", "dt.TableName can't be null ");
|
||||||
dt = GetCopyWriteDataTable(dt);
|
dt = GetCopyWriteDataTable(dt);
|
||||||
SqlBulkCopy copy = GetBulkCopyInstance();
|
DmBulkCopy copy = GetBulkCopyInstance();
|
||||||
copy.DestinationTableName = this.Builder.GetTranslationColumnName(dt.TableName);
|
copy.DestinationTableName = this.Builder.GetTranslationColumnName(dt.TableName);
|
||||||
copy.WriteToServer(dt);
|
copy.WriteToServer(dt);
|
||||||
CloseDb();
|
CloseDb();
|
||||||
@ -100,16 +101,16 @@ namespace SqlSugar
|
|||||||
result.TableName = dt.TableName;
|
result.TableName = dt.TableName;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private SqlBulkCopy GetBulkCopyInstance()
|
private DmBulkCopy GetBulkCopyInstance()
|
||||||
{
|
{
|
||||||
SqlBulkCopy copy;
|
DmBulkCopy copy;
|
||||||
if (this.Context.Ado.Transaction == null)
|
if (this.Context.Ado.Transaction == null)
|
||||||
{
|
{
|
||||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection);
|
copy = new DmBulkCopy((DmConnection)this.Context.Ado.Connection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection, SqlBulkCopyOptions.CheckConstraints, (SqlTransaction)this.Context.Ado.Transaction);
|
copy = new DmBulkCopy((DmConnection)this.Context.Ado.Connection, DmBulkCopyOptions.Default, (DmTransaction)this.Context.Ado.Transaction);
|
||||||
}
|
}
|
||||||
if (this.Context.Ado.Connection.State == ConnectionState.Closed)
|
if (this.Context.Ado.Connection.State == ConnectionState.Closed)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user