Commit Graph

4 Commits

Author SHA1 Message Date
9969417bd8 優化 FollowerController.cs 的子查詢性能
問題:
Line 345 將家族成員 ID 載入內存(ToList)
- 如果家族有 100+ 成員,載入 100-400 bytes

優化:
移除 ToList(),改為使用 IQueryable 子查詢
- var ccList = cc.ToList(); // 移除
- 直接使用 cc 進行 Contains 查詢
- 生成 SQL: WHERE num IN (SELECT...) OR leader IN (SELECT...)

效果:
✓ 減少內存占用:100-400 bytes → 0
✓ 完全在數據庫執行
✓ SQL 優化器可以更好地優化查詢計劃

對比:
- 原始版本(載入內存):2 次查詢
- 優化版本(子查詢):1 次查詢(最佳)
2025-11-12 17:30:53 +08:00
9a0d5ae700 修復 Batch 1 中 IEnumerable.Contains 的型別轉換問題
問題:
- Split().Select(int.Parse) 返回 IEnumerable<int>
- LINQ to Entities 中使用 Contains 需要具體集合類型

修復:
- 在所有 Split().Select() 後加 .ToList()
- 確保 EF 可以將 Contains 轉換為 SQL IN 子句

影響文件:
- memberController.cs (2 處)
- accountingController.cs (1 處)
- FollowerController.cs (1 處)
- stockController.cs (1 處)

技術說明:
LINQ to Entities 要求 Contains 的集合參數是具體化的集合(List/Array),
而不能是延遲執行的 IEnumerable,以便正確生成 SQL 查詢。
2025-11-12 17:01:49 +08:00
79b7dd114f 修復 Batch 1: FollowerController, memberController, accountingController, stockController
- FollowerController.cs: 8 處修復
- memberController.cs: 9 處修復
- accountingController.cs: 8 處修復
- stockController.cs: 8 處修復

總計 33 處,覆蓋會員、財務、庫存核心功能
2025-11-12 16:37:59 +08:00
af2c152ef6 migrate to new git 2025-08-29 01:27:25 +08:00