mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Advanced save WhereColumns Sqlite does not update the primary key
This commit is contained in:
@@ -30,6 +30,7 @@ namespace SqlSugar
|
||||
public bool IsNoUpdateNull { get; set; }
|
||||
public bool IsNoUpdateDefaultValue { get; set; }
|
||||
public List<string> PrimaryKeys { get; set; }
|
||||
public List<string> OldPrimaryKeys { get; set; }
|
||||
public bool IsOffIdentity { get; set; }
|
||||
public bool IsWhereColumns { get; set; }
|
||||
public bool? IsListUpdate { get; set; }
|
||||
|
@@ -189,6 +189,10 @@ namespace SqlSugar
|
||||
}
|
||||
//Check.Exception(UpdateObjs == null || UpdateObjs.Count() == 0, "UpdateObjs is null");
|
||||
int i = 0;
|
||||
if (this.EntityInfo.Columns.Any(it => it.IsPrimarykey))
|
||||
{
|
||||
this.UpdateBuilder.OldPrimaryKeys = this.EntityInfo.Columns.Where(it => it.IsPrimarykey).Select(it=>it.DbColumnName).ToList();
|
||||
}
|
||||
foreach (var item in UpdateObjs)
|
||||
{
|
||||
List<DbColumnInfo> updateItem = new List<DbColumnInfo>();
|
||||
|
@@ -15,7 +15,7 @@ namespace SqlSugar
|
||||
sb.AppendLine(string.Join("\r\n", groupList.Select(t =>
|
||||
{
|
||||
var updateTable = string.Format("UPDATE {0} SET", base.GetTableNameStringNoWith);
|
||||
var setValues = string.Join(",", t.Where(s => !s.IsPrimarykey).Select(m => GetOracleUpdateColums(i,m,false)).ToArray());
|
||||
var setValues = string.Join(",", t.Where(s => !s.IsPrimarykey).Where(s=> OldPrimaryKeys==null||!OldPrimaryKeys.Contains(s.DbColumnName)).Select(m => GetOracleUpdateColums(i,m,false)).ToArray());
|
||||
var pkList = t.Where(s => s.IsPrimarykey).ToList();
|
||||
List<string> whereList = new List<string>();
|
||||
foreach (var item in pkList)
|
||||
|
Reference in New Issue
Block a user