linq2db / linq2db.EntityFrameworkCore

Bring power of Linq To DB to Entity Framework Core projects
MIT License
462 stars 38 forks source link

FirstOrDefault does not work #201

Closed Simson43 closed 2 weeks ago

Simson43 commented 2 years ago

FirstOrDefault and the same methods dont work this (very simplified) example returns always 0:

context.Departments
                .Where(x => x.Employees.Where(y => y.Date == DateTime.Now).Select(y=>y.IsActive).FirstOrDefault() == false)
                .ToLinqToDB()
                .Count();

Version 3.17.0 EFCore3

sdanyliv commented 2 years ago

Use the following workaround before fix:

context.Departments
    .Where(x => !x.Employees.Any(y => y.Date == DateTime.Now && y.IsActive))
    .ToLinqToDB()
    .Count();
Simson43 commented 2 years ago

yes there are workarounds but would be nice to support such methods in the future versions thanks much!

MaceWindu commented 2 weeks ago

Cannot reproduce. Please reopen if you still observe this issue with additional details like used database type and generated SQL