EF Linq Error after change from dotnet Core 2.2.6 to 3.0.0

前端 未结 7 1967
刺人心
刺人心 2020-11-30 08:41

I\'m trying to upgrade a solution to the new Core Framework 3.0.0. Now I\'m having a small issue I don\'t understand.

Look, this method was unproblematic in 2.2.6:

相关标签:
7条回答
  • 2020-11-30 09:19

    The reason is that implicit client evaluation has been disabled in EF Core 3.

    What that means is that previously, your code didn't execute the WHERE clause on the server. Instead, EF loaded all rows into memory and evaluated the expression in memory.

    To fix this issue after the upgrade, first, you need to figure out what exactly EF can't translate to SQL. My guess would be the call to GetValueOrDefault(), therefore try rewriting it like this:

    .Where(x => x.BirthDate != null && x.BirthDate.Value.Month == DateTime.Now.Month)
    
    0 讨论(0)
提交回复
热议问题