-
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
ToListAsync returns wrong amount of rows when using TemporalAll and list projection #34978
Comments
It looks like a nested list projection with TemporalAll() doesn't work correctly. Because even with SplitQuery, the content of "RoleNames" is only correct for the first result. For the other items it's always empty. Therefor currently I have to fetch these RoleNames in a separate query:
|
Queries with joins (or includes or navigations) only really reliably work with AsOf operation. EF can guarantee a consistent graph and properly bucket the results. For all other operations, adding joins may cause all kinds of trouble. In your example, say, |
We should consider adding some guidance/warning in the documentation so that customers are aware of pitfalls of using those problematic operators in complex queries |
@maumar Will it ever be possible to make performant queries like this? I'm only creating those queries because it's a requirement for our projects to list the history of tables and relations while being able to sort and filter these rows. Also I can say it works the way I do it, at least for joining one relation, even though it's rather complicated / ugly. |
@Ben555555 honestly, I doubt we will be able to make it work. temporal all + navigations is fundamentally incompatible with how the feature has been implemented (relatively simple rewrite) I'm not sure if this can be done without some sort of N+1 strategy, like the one you employed in your previous comment. If that's the case, we would be very reluctant to make those transformations for you - we want to avoid cases where user write a seemingly simple query, and EF rewrites it into N+1 and drastically blows up the execution time |
Note that you can always query without Includes; you can use Join to define the exact query you want, or even do multiple queries and process/combine results client-side in whatever manner you want. |
I filed a documentation issue to provide some guidance on how to manually craft queries with navigations in non-AsOf scenarios as they are quite tricky to get right |
The variable result only contains 1 items when the following code is executed.
But when I analyze and execute the SQL query from the debugview there are actually 3 rows returned:
When I remove the projection part of "RoleNames" the correct amount of rows is returned. The only workaround I've found is to use AsSplitQuery(). Thefor is guess EF somehow thinks that the results are just duplicates and contains different entries for "RolesNames" (because this is a list in the projection). Also there are columns like RoleId and RoleId0 which I'm not sure why they are generated in the query.
Include provider and version information
EF Core version: 8.0.10
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0
Operating system:
IDE: Visual Studio 2022 17.10.
The text was updated successfully, but these errors were encountered: