fix(swap-eod): 用 MarginModes.ForLinq 替换 EF LINQ 中的 MarginModes.Contains

swap_position 的 EF 查询在 Where 里使用 MarginModes.Contains(x.InterestMode),
该静态方法无法被 EF Core 翻译成 SQL,导致有数据时抛 Translation failed。
改用 MarginModes.ForLinq(List<int> 形态)即可翻译为 IN (...)。
内存集合(details/interests 已 ToList)不受影响,无需改动。
This commit is contained in:
hjhan
2026-08-25 11:09:13 +08:00
parent d43e77ee6f
commit 7fff6e8236
@@ -3556,7 +3556,7 @@ namespace YLErp.Modules.SwapModule
// 主查询分页后再取同交易、同估值日的全部辅助腿,避免利息/保证金归集跨估值日串数据。
var eodPositions = DbContext.eod_swap_position.Where(interestPredicate).ToList();
var marginPositions = DbContext.swap_position
.Where(x => tradeIds.Contains(x.SwapTradeId) && MarginModes.Contains(x.InterestMode) && x.IsInitial && !x.Invalid)
.Where(x => tradeIds.Contains(x.SwapTradeId) && MarginModes.ForLinq.Contains(x.InterestMode) && x.IsInitial && !x.Invalid)
.ToList();
var tradeExtends = DbContext.trade_extend.Where(x => tradeIds.Contains(x.TradeId)).ToList();
Dictionary<string, bool> tradeDic = new Dictionary<string, bool>();