C#C
C#2y ago
Alex

What's wrong with my LINQ expression?

Hi! I'm trying to get data using LINQ expressions below. I use Sqlite
public async Task OnGetAsync()
{
    var now = DateTimeOffset.Now;

    LockedOutUsers =
        await _userManager
            .Users
            .Where(u => u.LockoutEnd != null && u.LockoutEnd > now)
            .OrderBy(u=>u.Email)
            .ToListAsync();

    OtherUsers = await _userManager
        .Users.Where(u => u.LockoutEnd == null || u.LockoutEnd <= now)
        .OrderBy(u => u.Email)
        .ToListAsync();
}

But I'm getting exception
InvalidOperationException: The LINQ expression 'DbSet<IdentityUser>() .Where(i => i.LockoutEnd != null && i.LockoutEnd.Value > __now_0)' could not be translated.
Was this page helpful?