{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6635","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6635/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6635/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6635/events","html_url":"https://github.com/aspnet/EntityFramework/issues/6635","id":180056951,"number":6635,"title":"Multiple left joins cause client side eval","user":{"login":"EricABC","id":13154635,"avatar_url":"https://avatars.githubusercontent.com/u/13154635?v=3","gravatar_id":"","url":"https://api.github.com/users/EricABC","html_url":"https://github.com/EricABC","followers_url":"https://api.github.com/users/EricABC/followers","following_url":"https://api.github.com/users/EricABC/following{/other_user}","gists_url":"https://api.github.com/users/EricABC/gists{/gist_id}","starred_url":"https://api.github.com/users/EricABC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricABC/subscriptions","organizations_url":"https://api.github.com/users/EricABC/orgs","repos_url":"https://api.github.com/users/EricABC/repos","events_url":"https://api.github.com/users/EricABC/events{/privacy}","received_events_url":"https://api.github.com/users/EricABC/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-09-29T13:58:37Z","updated_at":"2016-09-30T15:24:56Z","closed_at":null,"body":"### Steps to reproduce\r\nAlpha1-22262, should be after several left-join related fixes, such as #4588.  I was going to wait to post since this is on the edge of whats being worked on, but I couldn't find anything tracking this.\r\nRemoving the comments causes the query to fail.  With the comments, a single query is correctly executed.  I encountered the problem through a large variety of queries, but the one common factor seems to be more than one left join, which this simplified example shows.\r\n\r\n```c#\r\n                    var q3 = from i in items\r\n                             join innerD0 in values on i.Id equals innerD0.SparseItemId into d0g\r\n                             from d0pv in d0g.DefaultIfEmpty()\r\n                             //join innerD1 in values on i.Id equals innerD1.SparseItemId into d1g\r\n                             //from d1pv in d0g.DefaultIfEmpty()\r\n                             select new { SparseItemId = i.Id };\r\n```\r\n\r\nQueries executed:\r\n```\r\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory:Information: Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']\r\nSELECT [i].[Id], [innerD0].[SparseItemId], [innerD0].[PropertyId], [innerD0].[Data], [innerD0].[DateTimeOffsetValue], [innerD0].[DecimalValue], [innerD0].[DoubleValue], [innerD0].[StringValue]\r\nFROM [SparseItem] AS [i]\r\nLEFT JOIN [PropertyValue] AS [innerD0] ON [i].[Id] = [innerD0].[SparseItemId]\r\nORDER BY [i].[Id]\r\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory:Information: Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']\r\nSELECT [innerD1].[SparseItemId], [innerD1].[PropertyId], [innerD1].[Data], [innerD1].[DateTimeOffsetValue], [innerD1].[DecimalValue], [innerD1].[DoubleValue], [innerD1].[StringValue]\r\nFROM [PropertyValue] AS [innerD1]\r\n```\r\n\r\nThe query shaper pulls the second join source from a new query, causing the entire table to be selected.\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/250773917","html_url":"https://github.com/aspnet/EntityFramework/issues/6635#issuecomment-250773917","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6635","id":250773917,"user":{"login":"EricABC","id":13154635,"avatar_url":"https://avatars.githubusercontent.com/u/13154635?v=3","gravatar_id":"","url":"https://api.github.com/users/EricABC","html_url":"https://github.com/EricABC","followers_url":"https://api.github.com/users/EricABC/followers","following_url":"https://api.github.com/users/EricABC/following{/other_user}","gists_url":"https://api.github.com/users/EricABC/gists{/gist_id}","starred_url":"https://api.github.com/users/EricABC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricABC/subscriptions","organizations_url":"https://api.github.com/users/EricABC/orgs","repos_url":"https://api.github.com/users/EricABC/repos","events_url":"https://api.github.com/users/EricABC/events{/privacy}","received_events_url":"https://api.github.com/users/EricABC/received_events","type":"User","site_admin":false},"created_at":"2016-09-30T15:24:56Z","updated_at":"2016-09-30T15:24:56Z","body":"Also if it helps, the first group join will get to [here](https://github.com/aspnet/EntityFramework/blob/757e6d4b1bcdad9e4831321edb9ecf42f4007fbd/src/Microsoft.EntityFrameworkCore.Relational/Query/RelationalQueryModelVisitor.cs#L736).  If you comment out the second one, it gets inside.  Otherwise the value will be 2 and it will proceed to generate a new RelationalQueryModelVisitor and go client-side.  Hacking on it to force it to process the first left join shows that several things get out of alignment when there is a tree of left joins.  It's either not getting back to the original query source joined on, or its not able to perceive the previous source as the new effective flattened query after the first join."}}
{"actor":{"display_login":"EricABC"}}