Skip to content
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

Split query for non-navigation collections #21234

Closed
Tracked by #24107 ...
smitpatel opened this issue Jun 12, 2020 · 16 comments · Fixed by #24706
Closed
Tracked by #24107 ...

Split query for non-navigation collections #21234

smitpatel opened this issue Jun 12, 2020 · 16 comments · Fixed by #24706
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@smitpatel
Copy link
Member

customer.Select(c => new { c, Orders = c.Orders.Where(o => o.OrderId > 1000) });
customer.Select(c => new { c, OrderDates = c.Orders.Where(o => o.OrderId > 1000).Select(o => o.OrderDate) });
customer.Select(c => new { c, OrderDates = c.Orders.Where(o => o.OrderId > 1000).Select(o => o.OrderDate).Distinct() });
@smitpatel
Copy link
Member Author

Above queries

  1. is easy to do since columns are there, it is somewhat similar to Filtered include.
  2. requires adding columns in the projection which are not projection in order to form collections from 2nd query.
  3. is not possible in single query mode either since the additional columns required to identify different collections cannot be added due to Distinct.

@aahmadi458
Copy link

@smitpatel Any updates on this?

@aahmadi458
Copy link

aahmadi458 commented Nov 7, 2020

@smitpatel seems like a lot of people need this.
23 votes already.
How about you consider planning this for the next release?

@aahmadi458
Copy link

@smitpatel Know you guys are busy, but would you answer please? Thanks.

@ajcvickers
Copy link
Member

@aahmadi458 This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 5.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

@windhandel
Copy link

windhandel commented Nov 17, 2020

@ajcvickers I'm unclear on exactly what has been completed for this feature based on it currently saying in documentation that this has been partly included in the Preview 6.

I was paying particular attention to this feature because of the Logical Reads going exponential which are causing my larger queries to take minutes. This is caused by the cartesian product from the query generated by default from EF Core.

EFCoreSplitQueryIOExponential

Could you itemize which of these features are/will be delivered within EF Core v5? i.e. It will work with .Include, .ThenInclude and Projections?

@ajcvickers
Copy link
Member

@windhandel I believe the patterns not yet supported are the ones listed in this issue. @smitpatel should be able to confirm.

@smitpatel
Copy link
Member Author

Using collection navs in Include/ThenInclude can be done with split query. Using them in projection is not yet supported. The issue and documentation captures both.

@groege
Copy link

groege commented Jan 15, 2021

I also have the issue having developed with the preview for a while where this worked:

db.MyEntity.Select(x => new MyModel { MyParam = x.MyOtherEntity.Select(y => y.MyString).Distinct().ToList()).ToListAsync(ct);

Not a nice surprise finding out it does not actually work in the release version - seems like we have to stick to the prerelease till the end of the year at least until this hopefully is being released with ef6

@aradalvand
Copy link

aradalvand commented Jan 25, 2021

@smitpatel Any updates on this?!
It's among the most upvoted issues.
This feature was taken away from us in v3.0 I think, we're still waiting for it to make a comeback... Still nothing...

@smitpatel
Copy link
Member Author

@AradAral - This issue is planned for EF Core 6.0 the next release of EF Core.

@aradalvand
Copy link

@smitpatel Great to hear. Thanks!

@Aeroverra
Copy link

I Love the .Net ecosystem but why does it take a whole version change to fix this stuff? Migrated to 3.0 only to find out the Include API was butchered and then upgraded to 5.0 to find out the fix to that still has issues. This is the kind of thing that happens when you fix things that are not broken.

@johnkwaters
Copy link

I am really upset by this. I have been waiting ever since 2.2 for AsSplitQuery. And now that it's here, it can't handle the use case where it's needed! I fetch a deep object graph off my Trip object with the following includes:

{
"CurrentBreadcrumb",
"Route",
"Route.Driver",
"Route.StartsAt",
"Route.StartsAt.TimeZone",
"Stops",
"Stops.Location",
"Stops.Location.TimeZone",
"Stops.Location.Address",
"Stops.Location.Address.State",
"Driver",
"Legs",
"Stops.Activities",
"Stops.Activities.ActivityType",
"Stops.Activities.Properties",
"Stops.Activities.SurveyResult",
"Stops.Activities.Survey",
"TripErrors",
"TripErrors.Stop",
"Metrics"
});

2.2 did it fast. 3.0. 3.1 and 5.0 use tons of memory and take a minute. SplitQuery wont process it. Am I supposed to hand code all of the parts of assembling this tree? What's the point of an ORM then? Why did you remove this feature and not add back any compatibility?

@goldsam
Copy link

goldsam commented Mar 28, 2021

Kind of a big deal that OData is broken without this

@jsheetzati
Copy link

We purposely skipped EFCore 3.x because of the single vs split query difference between 2.x and 3.x. Now, I am trying to migrate to 5.x and enabled SplitQuery globally. However, because of this open issue, we are finding ourselves getting hit with random runtime exceptions.

Does Microsoft.EntityFrameworkCore.Analyzers detect this situation at compile time? We are looking for a way to detect this situation rather than waiting for runtime exceptions.

@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 21, 2021
smitpatel added a commit that referenced this issue Apr 21, 2021
smitpatel added a commit that referenced this issue Apr 21, 2021
smitpatel added a commit that referenced this issue Apr 22, 2021
@ghost ghost closed this as completed in #24706 Apr 22, 2021
ghost pushed a commit that referenced this issue Apr 22, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-preview5 Apr 26, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0-preview5, 6.0.0 Nov 8, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 2, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 3, 2021
bart-degreed pushed a commit to json-api-dotnet/JsonApiDotNetCore that referenced this issue Dec 8, 2021
* Update to .NET 6 with EF Core 6

* Adapt to changes in nullability annotations

* Adapt for breaking changes in PostgreSQL provider for EF Core 6

* Cleanup tests for handling special characters

* Removed workaround for dotnet/efcore#21026

* Removed workaround for dotnet/aspnetcore#33394

* Removed workaround for dotnet/aspnetcore#32097

* Removed workaround for dotnet/efcore#21234

* Updated to latest Resharper version and removed workarounds for earlier versions

* Applied new Resharper suggestions

* Package updates

* Renamed MSBuild variables

* Inlined MSBuild variables that are used only once

* Removed .BeCloseTo, now that fakers truncate time to whole milliseconds. Removed runtime casts, because the JSON deserializer now creates the correct types (based on the resource graph).

* Narrow service scope lifetime

* Enable registered services to dispose asynchronously, where possible

* Workaround for bug in cleanupcode

* Fixed detection of implicit many-to-many join entity in EF Core 6

* Activate implicit usings

* Switched to file-scoped namespaces

* Reformat solution

* Added [NoResource] to suppress startup warning

* Use Minimal Hosting APIs

* Removed duplicate code

* Corrected terminology for generic type usage

* Fixed warning: Type 'KnownResource' does not contain any attributes

* Updated roadmap and version table

* Fixed: Override IIdentifiable.Id with custom capabilities no longer worked

* Review feedback
nicolestandifer3 added a commit to nicolestandifer3/DotNet-Core-Json-Api that referenced this issue Aug 6, 2023
* Update to .NET 6 with EF Core 6

* Adapt to changes in nullability annotations

* Adapt for breaking changes in PostgreSQL provider for EF Core 6

* Cleanup tests for handling special characters

* Removed workaround for dotnet/efcore#21026

* Removed workaround for dotnet/aspnetcore#33394

* Removed workaround for dotnet/aspnetcore#32097

* Removed workaround for dotnet/efcore#21234

* Updated to latest Resharper version and removed workarounds for earlier versions

* Applied new Resharper suggestions

* Package updates

* Renamed MSBuild variables

* Inlined MSBuild variables that are used only once

* Removed .BeCloseTo, now that fakers truncate time to whole milliseconds. Removed runtime casts, because the JSON deserializer now creates the correct types (based on the resource graph).

* Narrow service scope lifetime

* Enable registered services to dispose asynchronously, where possible

* Workaround for bug in cleanupcode

* Fixed detection of implicit many-to-many join entity in EF Core 6

* Activate implicit usings

* Switched to file-scoped namespaces

* Reformat solution

* Added [NoResource] to suppress startup warning

* Use Minimal Hosting APIs

* Removed duplicate code

* Corrected terminology for generic type usage

* Fixed warning: Type 'KnownResource' does not contain any attributes

* Updated roadmap and version table

* Fixed: Override IIdentifiable.Id with custom capabilities no longer worked

* Review feedback
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.