mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update pg sql
This commit is contained in:
parent
2862cb83b2
commit
bc7e823e93
@ -54,7 +54,15 @@ namespace OrmTest
|
|||||||
var result5 = db.Updateable(updateObj).WhereColumns(it => new { it.Id }).ExecuteCommand();//update single by id
|
var result5 = db.Updateable(updateObj).WhereColumns(it => new { it.Id }).ExecuteCommand();//update single by id
|
||||||
var result6 = db.Updateable(updateObjs).WhereColumns(it => new { it.Id }).ExecuteCommand();//update List<Class> by id
|
var result6 = db.Updateable(updateObjs).WhereColumns(it => new { it.Id }).ExecuteCommand();//update List<Class> by id
|
||||||
|
|
||||||
|
var result67 =
|
||||||
|
db.Updateable(updateObjs)
|
||||||
|
.PublicSetColumns(it => it.Price, it => it.Price + 1)
|
||||||
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
var result68 =
|
||||||
|
db.Updateable(updateObjs.First())
|
||||||
|
.PublicSetColumns(it => it.Price, it => it.Price + 1)
|
||||||
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
/*** 2.by expression ***/
|
/*** 2.by expression ***/
|
||||||
|
@ -198,8 +198,25 @@ namespace SqlSugar
|
|||||||
batchUpdateSql.Replace("${0}", format);
|
batchUpdateSql.Replace("${0}", format);
|
||||||
batchUpdateSql.Append(";");
|
batchUpdateSql.Append(";");
|
||||||
}
|
}
|
||||||
|
batchUpdateSql = GetBatchUpdateSql(batchUpdateSql);
|
||||||
return batchUpdateSql.ToString();
|
return batchUpdateSql.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StringBuilder GetBatchUpdateSql(StringBuilder batchUpdateSql)
|
||||||
|
{
|
||||||
|
if (ReSetValueBySqlExpListType == null && ReSetValueBySqlExpList != null)
|
||||||
|
{
|
||||||
|
var result = batchUpdateSql.ToString();
|
||||||
|
foreach (var item in ReSetValueBySqlExpList)
|
||||||
|
{
|
||||||
|
var dbColumnName = item.Value.DbColumnName;
|
||||||
|
result = result.Replace($"{dbColumnName}=T.{dbColumnName}", $"{dbColumnName}={item.Value.Sql.Replace(dbColumnName,$"{Builder.GetTranslationColumnName( this.TableName)}.{dbColumnName}")}");
|
||||||
|
batchUpdateSql = new StringBuilder(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return batchUpdateSql;
|
||||||
|
}
|
||||||
protected override string GetJoinUpdate(string columnsString, ref string whereString)
|
protected override string GetJoinUpdate(string columnsString, ref string whereString)
|
||||||
{
|
{
|
||||||
var formString = $" {Builder.GetTranslationColumnName(this.TableName)} AS {Builder.GetTranslationColumnName(this.ShortName)} ";
|
var formString = $" {Builder.GetTranslationColumnName(this.TableName)} AS {Builder.GetTranslationColumnName(this.ShortName)} ";
|
||||||
|
Loading…
Reference in New Issue
Block a user