Browse Source

MySql bluk copy support set chara

pull/2/head
SUNKAIXUAN 4 years ago
parent
commit
273880f5c2
  1. 28
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlBlueCopy.cs

28
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlBlueCopy.cs

@ -14,6 +14,7 @@ namespace SqlSugar
internal SqlSugarProvider Context { get; set; }
internal ISqlBuilder Builder { get; set; }
internal T[] Entitys { get; set; }
internal string Chara { get; set; }
private MySqlBlueCopy()
{
@ -24,7 +25,13 @@ namespace SqlSugar
this.Builder = builder;
this.Entitys = entitys;
}
public bool ExecuteBlueCopy(string chara)
{
this.Chara = chara;
return ExecuteBlueCopy();
}
public bool ExecuteBlueCopy()
{
var IsBulkLoad = false;
@ -76,7 +83,7 @@ namespace SqlSugar
// IsolationLevel.Parse
MySqlBulkLoader bulk = new MySqlBulkLoader(conn)
{
CharacterSet = "UTF8",
CharacterSet = GetChara(),
FieldTerminator = ",",
FieldQuotationCharacter = '"',
EscapeCharacter = '"',
@ -105,11 +112,28 @@ namespace SqlSugar
return IsBulkLoad; ;
}
private string GetChara()
{
if (this.Chara == null)
{
return "UTF8";
}
else
{
return this.Chara;
}
}
public Task<bool> ExecuteBlueCopyAsync()
{
return Task.FromResult(ExecuteBlueCopy());
}
public Task<bool> ExecuteBlueCopyAsync(string chara)
{
this.Chara = chara;
return Task.FromResult(ExecuteBlueCopy());
}
private void CloseDb()
{

Loading…
Cancel
Save