Synchronization code

This commit is contained in:
sunkaixuan 2024-02-03 14:30:33 +08:00
parent f5f72c1631
commit 39a09fd445

View File

@ -76,19 +76,24 @@ namespace SqlSugar
{
using (var cmd = cn.CreateCommand())
{
cmd.CommandText = this.Context.Insertable(dictionary.First()).AS(dt.TableName).ToSql().Key.Replace(";SELECT LAST_INSERT_ROWID();","");
cmd.CommandText = this.Context.Insertable(dictionary.First()).AS(dt.TableName).ToSql().Key.Replace(";SELECT LAST_INSERT_ROWID();", "");
var isCorrectErrorSqlParameterName = this.Context?.CurrentConnectionConfig?.MoreSettings?.IsCorrectErrorSqlParameterName == true;
foreach (DataRow dataRow in dt.Rows)
{
int correctParameterIndex = 0;
foreach (DataColumn item in dt.Columns)
{
if (IsBoolTrue(dataRow, item))
if (isCorrectErrorSqlParameterName)
{
cmd.Parameters.AddWithValue("@" + item.ColumnName, true);
if (!cmd.CommandText.Contains("@" + item.ColumnName))
{
cmd.Parameters.AddWithValue($"@CrorrPara{correctParameterIndex}", dataRow[item.ColumnName]);
correctParameterIndex++;
}
else if (IsBoolFalse(dataRow, item))
else
{
cmd.Parameters.AddWithValue("@" + item.ColumnName, false);
cmd.Parameters.AddWithValue("@" + item.ColumnName, dataRow[item.ColumnName]);
}
}
else
{