2.2 -> 5.0.5 (.Net Core 3.1) strange subquery in simple select with Include
See original GitHub issueI’ve first posted to npgsql (https://github.com/npgsql/efcore.pg/issues/1808), but it works the same with sqlite
var deliveryChannel = dbContext.DeliveryChannel.AsNoTrackingWithIdentityResolution().Include(c => c.ClientData).ThenInclude(c => c.DeliveryChannel).Where(c => (c.State == State.Active && c.ExtendedData == "someData") ).OrderByDescending(d => d.Id).FirstOrDefaultAsync().Result;
ClientData has a collection of DeliveryChannels. I’m selecting all DeliveryChannels from the Client of some exact DeliveryChannel (why not? 😃 ).
and it produces strange subquery in first select of split query (in EF 2.2 there is no subquery):
public class ClientData
{
...
public virtual ICollection<DeliveryChannel> DeliveryChannel { get; set; }
}
public class DeliveryChannel{
...
public int ClientDataId { get; set; }
public ClientData ClientData { get; set; }
}
options.UseSqlite("Data Source=sqlitedemo.db", p => p.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery));
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
EF Core 5 - Does the order of Include()/Where() methods in ...
When this runs in EF Core 3.1 (2.2 and 3.0 are similar) it generates a SQL statement with two subqueries, one to join...
Read more >Migrate from ASP.NET Core 3.1 to 5.0
Learn how to migrate an ASP.NET Core 3.1 project to ASP.NET Core 5.0.
Read more >Using a Subquery in a SELECT statement - Simple Talk
When a SELECT statement is embedded within another statement it is known as a subquery. There are two types of subqueries: basic subquery...
Read more >Appendix C. MySQL Change History
This appendix lists the changes from version to version in the MySQL source code through the latest version of MySQL 6.0, which is...
Read more >SQL Injection
A vulnerability, which was classified as critical, has been found in SourceCodester Simple Chat System 1.0. Affected by this issue is some unknown...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@smitpatel Do you know sql? 😃 Have a look at the underlined lines (in the picture) and you will see that inner select is with limit 1, so it is not needed to do subquery and order by in outer query. In 2.2 it was a simple select without subquery. It’a pity EF is not consistent and every new version brings some hidden surprises…
It requires some big changes happened in 6.0 so sadly the earlier release will be 6.0-preview5