diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs index c8657c79f..9683a181e 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs @@ -30,6 +30,7 @@ namespace SqlSugar public bool IsNoUpdateNull { get; set; } public bool IsNoUpdateDefaultValue { get; set; } public List PrimaryKeys { get; set; } + public List OldPrimaryKeys { get; set; } public bool IsOffIdentity { get; set; } public bool IsWhereColumns { get; set; } public bool? IsListUpdate { get; set; } diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs index 582c34f39..c0788e919 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs @@ -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 updateItem = new List(); diff --git a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs index d153bbb74..a0302cb54 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs @@ -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 whereList = new List(); foreach (var item in pkList)