0

尝试使用一组数据库对象时出现错误。

using (var context = new Entities())
{
    var allRates = context.CurrencyRate;
    var rates = new List<CurrencyRate>();
    //get rates for selected currency types
    foreach (var newRate in newCurrencyRateList)
    {
        rates.AddRange(allRates.Where(r => r.CurrencyTypeId == newRate.CurrencyId).OrderByDescending(r => r.CreatedDate).ToList().Take(4));
    }

    //Delete old rates
    var oldRates = allRates.Except(rates);
    if (oldRates != null && oldRates.Any())
    {
        ....
    }
}

Entity() - 数据模型。

我得到一个错误

oldRates.Any()

如何修复?

4

0 回答 0