mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-19 06:29:33 +08:00
34 lines
959 B
C#
34 lines
959 B
C#
using MySqlConnector;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SqlSugar
|
|
{
|
|
public partial class MySqlFastBuilder : FastBuilder, IFastBuilder
|
|
{
|
|
private async Task<int> MySqlConnectorBulkCopy(DataTable dt)
|
|
{
|
|
try
|
|
{
|
|
this.Context.Open();
|
|
var tran = (MySqlTransaction)this.Context.Ado.Transaction;
|
|
var connection = (MySqlConnection)this.Context.Ado.Connection;
|
|
MySqlBulkCopy bulkCopy = new MySqlBulkCopy(connection, tran);
|
|
bulkCopy.DestinationTableName= dt.TableName;
|
|
await bulkCopy.WriteToServerAsync(dt);
|
|
return dt.Rows.Count;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
CloseDb();
|
|
}
|
|
}
|
|
}
|
|
} |