From e20b250944ca9a114609c87d52d45819d88ce8e9 Mon Sep 17 00:00:00 2001 From: yiming Date: Wed, 12 Nov 2025 17:12:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=BE=A9=20FilesSetController.cs=20?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E9=A1=9E=E5=9E=8B=E9=8C=AF=E8=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 問題: 1. CS1061: files_num 是 int 類型,不是 int? - 錯誤地使用了 HasValue 和 .Value 2. CS0019: Count 應該使用方法調用 Count() 修復: - 第 93 行:移除 HasValue 和 .Value 改為直接使用 ids.Contains(q.files_num) - 第 94 行:Count 改為 Count() 根因分析: 在 Model.actItem_files 中,files_num 定義為 int 類型 而不是 Nullable,因此不需要 nullable 處理。 --- web/App_Code/api/FilesSetController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/App_Code/api/FilesSetController.cs b/web/App_Code/api/FilesSetController.cs index afd7a51..fd8af69 100644 --- a/web/App_Code/api/FilesSetController.cs +++ b/web/App_Code/api/FilesSetController.cs @@ -90,8 +90,8 @@ public class FilesSetController : ApiController if (prod.Count() > 0) { //刪除品項的相關文件 - var prod2 = _db.actItem_files.Where(q => q.files_num.HasValue && ids.Contains(q.files_num.Value)).ToList(); - if (prod2.Count > 0) + var prod2 = _db.actItem_files.Where(q => ids.Contains(q.files_num)).ToList(); + if (prod2.Count() > 0) { _db.actItem_files.RemoveRange(prod2); }