© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
35 replies
FusedQyou

✅ This EntityFramework query can not be translated for SQLite

The issue lies within
Intersect
Intersect
. The point of the query is to fetch the current user, and to populate
LikedByUsers
LikedByUsers
with matched users. An user is matched when he appears in
LikedByUsers
LikedByUsers
and
LikedUsers
LikedUsers
. How can I make this work for SQLite?
Error:
"Translating this query requires the SQL APPLY operation, which is not supported on SQLite."
"Translating this query requires the SQL APPLY operation, which is not supported on SQLite."

private IQueryable<DataUser> CreateGetAllMatchedUsersQuery(DataUser user, bool includeDeleted)
    {
        var query = this._databaseContext.Users.AsQueryable();
        query = query.Where(x => x.Id == user.Id);

        // Ensure no deleted users are returned if specified not to.
        if (!includeDeleted)
        {
            query = query.Where(x => !x.Deleted);
            query = query.Include(x => x.LikedByUsers.Where(y => !y.Deleted));
            query = query.Include(x => x.LikedUsers.Where(y => !y.Deleted));
        }
        else
        {
            query = query.Include(x => x.LikedByUsers);
            query = query.Include(x => x.LikedUsers);
        }

        // Select all matches
        query = query.SelectMany(x => x.LikedByUsers.Intersect(x.LikedUsers));
        return query;
    }
private IQueryable<DataUser> CreateGetAllMatchedUsersQuery(DataUser user, bool includeDeleted)
    {
        var query = this._databaseContext.Users.AsQueryable();
        query = query.Where(x => x.Id == user.Id);

        // Ensure no deleted users are returned if specified not to.
        if (!includeDeleted)
        {
            query = query.Where(x => !x.Deleted);
            query = query.Include(x => x.LikedByUsers.Where(y => !y.Deleted));
            query = query.Include(x => x.LikedUsers.Where(y => !y.Deleted));
        }
        else
        {
            query = query.Include(x => x.LikedByUsers);
            query = query.Include(x => x.LikedUsers);
        }

        // Select all matches
        query = query.SelectMany(x => x.LikedByUsers.Intersect(x.LikedUsers));
        return query;
    }
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

Similar Threads

Sqlite Entityframework
C#CC# / help
4y ago
✅ could not be translated
C#CC# / help
17mo ago
GroupBy cannot be translated using
C#CC# / help
4y ago
LINQ expression could not be translated after converting object
C#CC# / help
4y ago