修正多處 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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user