From 65f9dd14200a029117bf4809ccce02f886e2d6f2 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 3 Dec 2023 17:00:03 +0800 Subject: [PATCH] Synchronization code --- Src/Asp.Net/SqlSugar/Abstract/GridSave/GridSaveProvider.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/GridSave/GridSaveProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/GridSave/GridSaveProvider.cs index 805a80d86..ee6d91fb2 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/GridSave/GridSaveProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/GridSave/GridSaveProvider.cs @@ -55,12 +55,14 @@ namespace SqlSugar public List GetDeleteList() { + //下面代码ToDictionary会有重复错请修改 string[] primaryKeys = this.Context.EntityMaintenance.GetEntityInfo().Columns.Where(it => it.IsPrimarykey).Select(it => it.PropertyName).ToArray(); - var saveListDictionary = this.SaveList.ToDictionary(item => CreateCompositeKey(primaryKeys, item)); + var saveListDictionary = this.SaveList.Select(item => + new { Key = CreateCompositeKey(primaryKeys, item), Value = item }); var deleteList = this.OldList.Where(oldItem => { var compositeKey = CreateCompositeKey(primaryKeys, oldItem); - return !saveListDictionary.ContainsKey(compositeKey); + return !saveListDictionary.Any(it=>it.Key==compositeKey); }).ToList(); return deleteList; }