无法确定序列化信息 IIF

Unable to determine the serialization information IIF

我有一个价格范围查询,我正在尝试为我的 C# 代码编写,根据产品的货币类型,我需要查询正确的字段

var minPrice = builder.Gte(s => s.Price.CurrencyCode == "USD" ? s.Price.Usd : s.Price.Foreign, filter.MinPrice);
var maxPrice = builder.Lte(s => s.Price.CurrencyCode == "USD" ? s.Price.Usd : s.Price.Foreign, filter.MaxPrice);

但是当我 运行 测试这个代码时,我得到以下错误:

Unable to determine the serialization information for s => IIF((s.Price.CurrencyCode == ""USD""), s.Price.Usd, s.Price.Foreign).

如果我取出三元组并只查找美国价格,它会完美运行,但我需要能够让它也查找非美国价格,我做错了什么吗?

不确定这里发生了什么(我认为这种查询还不受支持)但是你如何重写查询:

    var minPrice = (builder.Where(s => s.Price.CurrencyCode == "USD") & builder.Gte(s => s.Price.Usd, filter.MinPrice))
                 | (builder.Where(s => s.Price.CurrencyCode != "USD") & builder.Gte(s => s.Price.Foreign, filter.MinPrice));
    var maxPrice = (builder.Where(s => s.Price.CurrencyCode == "USD") & builder.Lte(s => s.Price.Usd, filter.MaxPrice))
                 | (builder.Where(s => s.Price.CurrencyCode != "USD") & builder.Lte(s => s.Price.Foreign, filter.MaxPrice));