Browse Source

Synchronization code

pull/32/head
sunkaixuan 2 years ago
parent
commit
fd3844d86b
  1. 10
      Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs
  2. 13
      Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs

10
Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs

@ -26,6 +26,16 @@ namespace SqlSugar
";
}
}
protected override string GetJoinUpdate(string columnsString, ref string whereString)
{
var joinString = $" {Builder.GetTranslationColumnName(this.TableName)} {Builder.GetTranslationColumnName(this.ShortName)} ";
foreach (var item in this.JoinInfos)
{
joinString += $"\r\n JOIN {Builder.GetTranslationColumnName(item.TableName)} {Builder.GetTranslationColumnName(item.ShortName)} ON {item.JoinWhere} ";
}
var tableName = joinString+ "\r\n ";
return string.Format(SqlTemplate, tableName, columnsString, whereString);
}
protected override string TomultipleSqlString(List<IGrouping<int, DbColumnInfo>> groupList)
{
Check.Exception(PrimaryKeys == null || PrimaryKeys.Count == 0, " Update List<T> need Primary key");

13
Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs

@ -200,5 +200,18 @@ namespace SqlSugar
}
return batchUpdateSql.ToString();
}
protected override string GetJoinUpdate(string columnsString, ref string whereString)
{
var formString = $" {Builder.GetTranslationColumnName(this.TableName)} AS {Builder.GetTranslationColumnName(this.ShortName)} ";
var joinString = "";
foreach (var item in this.JoinInfos)
{
whereString += " AND "+item.JoinWhere;
joinString += $"\r\n FROM {Builder.GetTranslationColumnName(item.TableName)} {Builder.GetTranslationColumnName(item.ShortName)} ";
}
var tableName = formString + "\r\n ";
columnsString = columnsString.Replace(Builder.GetTranslationColumnName(this.ShortName)+".","")+joinString;
return string.Format(SqlTemplate, tableName, columnsString, whereString);
}
}
}

Loading…
Cancel
Save