✅ This EntityFramework query can not be translated for SQLite
The issue lies within
Intersect
. The point of the query is to fetch the current user, and to populate LikedByUsers
with matched users. An user is matched when he appears in LikedByUsers
and LikedUsers
. How can I make this work for SQLite?
Error: "Translating this query requires the SQL APPLY operation, which is not supported on SQLite."
16 Replies
I suppose this awful query can do the same...
query = query.SelectMany(x => x.LikedByUsers.Where(y => x.LikedUsers.Any(z => z == x)));
yeah, or just
.Contains
instead of Any
should also workI was wrong, the same error is returned. Would it be because of
SelectMany
?no, selectmany is supported
oh, it says it's not supported specifically for sqlite
Welp
there are certain things that don't work on sqlite
for example sequences
search for workarounds specifically for sqlite
Working on it... Unsure what an alternative would be
Specifically on how to cast IQueryable<IEnumerable<DataUser>> back to IQueryable<DataUser>
I don't get it, I turned it into this, and I still get the error.
Worked around every single thing I could think of and it still complains
@AntonC Sorry for pinging, but maybe you know a solution for this.
It's the same idea, I want to get the matches, but I am now trying to get it from a DataUserLike class.
The problem is that I somehow need to determine if there is an instance where one user is Liked and LikedBy another user, and the other way around. This would return a list of users that the specified user matched with. I'm having a bit of a brain fart after everything, so excuse me if the solution is simple.
Problem with this is: How can I figure out if a Liked/LikedBy id matches that of another row in the same query?
yeah idk how to do stuff like this
I'd probably split this into two queries
Split it up?
AsSplitQuery might help
Not sure how, but I'll take a look
yeah me neither
just a gut feel
I think I did it
No idea how AsSplitQuery works, but I was reading about complex queries, and ended up using this:
There are probably a million ways to improve this
Works in SQLite too
@AntonC I believe the query joins itself, and then based on a predicate selects every entry that equals two likes, pretty much.
The userQuery is a simple "Get the user if the id matches since we need the other one"
I wonder if it can be written in plain linq
yeah makes sense
you'll probably want an index for it too
Never thought I would have such issues with EF
Right
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Closed!