From 3175ce6c1d2d207facb923a2bc348ada826ae848 Mon Sep 17 00:00:00 2001 From: Marvin Date: Wed, 6 Sep 2023 21:44:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E7=BB=93?= =?UTF-8?q?=E8=BD=AC=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E6=97=A7?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AMES/BarcodeInfoesController.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs index a8a392aa..131dd47a 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs @@ -377,6 +377,17 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } else { + //删除旧组件 + var oldBarcodeItem = await _context.BarcodeItems.Where(m => m.BarcodeID == barcodeInfo[0].BarcodeID).ToListAsync(); + if (oldBarcodeItem != null) + { + for (int i = 0; i < oldBarcodeItem.Count; i++) + { + _context.BarcodeItems.Remove(oldBarcodeItem[0]); + await _context.SaveChangesAsync(); + } + } + _context.Entry(barcodeInfo[0]).State = EntityState.Modified; //設置容器空間某一個模型的某一個欄位 不提交到資料庫 _context.Entry(barcodeInfo[0]).Property("CreateDate").IsModified = false;