修正多處 LINQ-to-Entities 查詢,避免 Nullable .Contains()、.ToString()、Request[] 直接使用造成翻譯失敗。

API 查詢同步改寫 .Contains()、.OrderBy()、複雜 GroupBy/Math.Round,必要時 materialize 或加 HasValue。
Participation rate / kind breakdown 改在記憶體計算,同時檢查整數陣列 .Contains() 的型別安全性。
This commit is contained in:
2025-11-14 23:40:55 +08:00
parent 4fcbfb3801
commit 27f916eb9c
14 changed files with 245 additions and 115 deletions

View File

@@ -208,10 +208,12 @@ public class accountingController : BaseApiController
}
else if (sortBy.Equals("total"))
{
// ❌ 錯誤寫法: qry.OrderByDescending(o => o.price??0+o.tax??0)
// 運算符優先級問題,應該加括號確保正確運算
if (sortDesc)
qry = qry.OrderByDescending(o => o.price??0+o.tax??0);
qry = qry.OrderByDescending(o => (o.price ?? 0) + (o.tax ?? 0));
else
qry = qry.OrderBy(o => o.price ?? 0 + o.tax ?? 0);
qry = qry.OrderBy(o => (o.price ?? 0) + (o.tax ?? 0));
}
else
qry = qry.OrderByDescending(o => o.num);