修复更新时没有删除子表的错误

This commit is contained in:
2023-06-30 11:02:44 +08:00
parent 43f8c50c7e
commit f86e10c845

View File

@@ -998,6 +998,7 @@ public class RunService : IRunService, ITransient
if (childTable != null)
{
if (!model.Any(x => x.ContainsKey("id"))) mainSql.Add(string.Format("delete from {0} where {1}='{2}';", childTable?.table, childTable.tableField, id));
else mainSql.Add(string.Format("delete from {0} where {1} not in ('{2}') and {3}='{4}';", childTable?.table, childTable.fields.First(x => x.PrimaryKey.Equals(1)).Field, string.Join("','", model.Where(x => x.ContainsKey("id")).Select(x => x["id"]).ToList()), childTable.tableField, id));
tableList = new List<DbTableFieldModel>();
tableList = _databaseService.GetFieldList(link, childTable?.table);
DbTableFieldModel? childPrimary = tableList.Find(t => t.primaryKey);