EF Linq Error after change from dotnet Core 2.2.6 to 3.0.0

前端 未结 7 1987
刺人心
刺人心 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条回答
  •  旧时难觅i
    2020-11-30 09:18

    As Daniel Hilgarth wrote his solution is fine and works. The Addition of Wiktor Zychla seems to work, too. I rewrote the method as follows:

    public async Task> GetBirthdayUsersCurrentMonth()
        {
            return await ApplicationDbContext.Users
                .Where(x => x.Gender != ApplicationUser.GenderTypes.generic)
                //.Where(x => x.BirthDate.GetValueOrDefault().Month == DateTime.Now.Month)
                .Where(x => x.BirthDate.Value.Month == DateTime.Now.Month)
                .Where(x => x.RetireDate == null)
                .OrderBy(x => x.BirthDate)
                .ToListAsync();
        }
    

    So, as it seems in Core 3.0.0 it's not a good idea to use as mentioned evaluation-methods event if these are standard methods served by the classes itself.

    Thanks for your help.

提交回复
热议问题