-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThenInclude after Take on a ICollection Property generate a wrong sql #23041
Comments
Just to add a detail might be useful, I wrote that if I use ToArray no exception is raised, so: Works. But actually if I add a Skip at the end, ToArray doesn't work either :
Same exception is raised Regards |
I get the same error with var conversations = await dbContext.Conversations
.Include(a => a.ConversationMessages.Take(1))
.ThenInclude(a => a.SentByUser)
.Take(1)
.ToListAsync(); The generated query looks like this if it's to any help: SELECT [t].[id], [t].[subject], [t].[updated], [t1].[id], [t1].[conversation_id], [t1].[sent], [t1].[sent_by_user_id], [t1].[text], [t1].[id0], [t1].[absent], [t1].[access_failed_count], [t1].[active], [t1].[concurrency_stamp], [t1].[connected], [t1].[created], [t1].[email], [t1].[email_confirmed], [t1].[first_name], [t1].[image], [t1].[is_ad_user], [t1].[last_name], [t1].[lockout_enabled], [t1].[lockout_end], [t1].[normalized_email], [t1].[normalized_user_name], [t1].[password_hash], [t1].[phone_number], [t1].[phone_number_confirmed], [t1].[pin_password_hash], [t1].[profession_id], [t1].[security_stamp], [t1].[two_factor_enabled], [t1].[updated], [t1].[user_name], [t1].[windows_user_name]
FROM (
SELECT TOP(1) [c].[id], [c].[subject], [c].[updated]
FROM [conversations] AS [c]
) AS [t]
OUTER APPLY (
SELECT [t].[id], [t].[conversation_id], [t].[sent], [t].[sent_by_user_id], [t].[text], [u].[id] AS [id0], [u].[absent], [u].[access_failed_count], [u].[active], [u].[concurrency_stamp], [u].[connected], [u].[created], [u].[email], [u].[email_confirmed], [u].[first_name], [u].[image], [u].[is_ad_user], [u].[last_name], [u].[lockout_enabled], [u].[lockout_end], [u].[normalized_email], [u].[normalized_user_name], [u].[password_hash], [u].[phone_number], [u].[phone_number_confirmed], [u].[pin_password_hash], [u].[profession_id], [u].[security_stamp], [u].[two_factor_enabled], [u].[updated], [u].[user_name], [u].[windows_user_name]
FROM (
SELECT TOP(1) [c0].[id], [c0].[conversation_id], [c0].[sent], [c0].[sent_by_user_id], [c0].[text]
FROM [conversation_messages] AS [c0]
WHERE [t].[id] = [c0].[conversation_id]
) AS [t0]
INNER JOIN [users] AS [u] ON [t].[sent_by_user_id] = [u].[id]
) AS [t1]
ORDER BY [t].[id], [t1].[id], [t1].[id0]
GO If I remove the |
Am I doing it wrong or is this still a thing ? Or is the fix only implemented to the .NET 6 version of the library.. -_- mstsc_esVNU3vQTJ.mp4 |
Hello all.
EF 5.0.0-rc.2.20475.6
using this semplificate :
using this query :
throw the exception :
No exception if I remove the Take(10) or if i use ToArray instead of FirstOrDefault
attached the project that reproduce the issue
EF.zip
The text was updated successfully, but these errors were encountered: