© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
55 replies
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();
}
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.
InvalidOperationException: The LINQ expression 'DbSet<IdentityUser>() .Where(i => i.LockoutEnd != null && i.LockoutEnd.Value > __now_0)' could not be translated.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

❔ System.Linq.Expressions custom expression
C#CC# / help
3y ago
Await Linq Expression
C#CC# / help
4y ago
MongoDB.Driver.Linq.ExpressionNotSupportedException: ' Expression not supported: i.ToClaim()
C#CC# / help
14mo ago
LINQ Lambda-Expression Diff
C#CC# / help
4y ago