Update sqlite bulkcopy

This commit is contained in:
sunkaixuan 2024-02-06 16:24:06 +08:00
parent 29fbc5c593
commit 5c77c7269f

View File

@ -75,6 +75,13 @@ namespace SqlSugar
private async Task<int> _BulkCopy(DataTable dt, List<Dictionary<string, object>> dictionary, int i, SqliteConnection cn)
{
using (var cmd = cn.CreateCommand())
{
if (this.Context?.CurrentConnectionConfig?.MoreSettings?.IsCorrectErrorSqlParameterName == true)
{
cmd.CommandText = this.Context.Insertable(dictionary.First()).AS(dt.TableName).ToSqlString().Replace(";SELECT LAST_INSERT_ROWID();", "");
i += await cmd.ExecuteNonQueryAsync();
}
else
{
cmd.CommandText = this.Context.Insertable(dictionary.First()).AS(dt.TableName).ToSql().Key.Replace(";SELECT LAST_INSERT_ROWID();", "");
foreach (DataRow dataRow in dt.Rows)
@ -98,11 +105,22 @@ namespace SqlSugar
cmd.Parameters.Clear();
}
}
}
return i;
}
private async Task<int> _BulkUpdate(DataTable dt, List<Dictionary<string, object>> dictionary, int i,string [] whereColums,string [] updateColums, SqliteConnection cn)
{
using (var cmd = cn.CreateCommand())
{
if (this.Context?.CurrentConnectionConfig?.MoreSettings?.IsCorrectErrorSqlParameterName == true)
{
cmd.CommandText = this.Context.Updateable(dictionary.First())
.WhereColumns(whereColums)
.UpdateColumns(updateColums)
.AS(dt.TableName).ToSqlString();
i += await cmd.ExecuteNonQueryAsync();
}
else
{
cmd.CommandText = this.Context.Updateable(dictionary.First())
.WhereColumns(whereColums)
@ -130,6 +148,7 @@ namespace SqlSugar
cmd.Parameters.Clear();
}
}
}
return i;
}