{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6177","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6177/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6177/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6177/events","html_url":"https://github.com/aspnet/EntityFramework/issues/6177","id":167831319,"number":6177,"title":"Have a problem with a simple left join with possible nulls.","user":{"login":"Bartmax","id":3386797,"avatar_url":"https://avatars.githubusercontent.com/u/3386797?v=3","gravatar_id":"","url":"https://api.github.com/users/Bartmax","html_url":"https://github.com/Bartmax","followers_url":"https://api.github.com/users/Bartmax/followers","following_url":"https://api.github.com/users/Bartmax/following{/other_user}","gists_url":"https://api.github.com/users/Bartmax/gists{/gist_id}","starred_url":"https://api.github.com/users/Bartmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bartmax/subscriptions","organizations_url":"https://api.github.com/users/Bartmax/orgs","repos_url":"https://api.github.com/users/Bartmax/repos","events_url":"https://api.github.com/users/Bartmax/events{/privacy}","received_events_url":"https://api.github.com/users/Bartmax/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-27T11:24:48Z","updated_at":"2016-07-27T11:32:07Z","closed_at":null,"body":"This is very counter intuitive, I'm not sure what's going on.\r\nMy goal was to get the 4 database entries, with null on Logo when Details is null.\r\nI tried different approaches and i found it very inconsistent.\r\n\r\nSo obvious question is:  is it possible to get all rows, left join with default if empty?\r\nQuestion 2: Am I doing something wrong or this is a bug?\r\n\r\n\r\nDatabase has 4 entries, 2 with null details.\r\n\r\nthis query returns 2 results:\r\n```\r\nvar query1 = await context.Games\r\n    .Include(g=>g.Details)\r\n    .ThenInclude(d=>d.Logo)\r\n    .Select(g=> new { Logo = g.Details.Logo, g.Title, g.GameId })\r\n    .ToListAsync();\r\n```\r\n<hr>\r\nthis query returns 4 results:\r\n```\r\nvar query2 = await context.Games\r\n    .Include(g=>g.Details)\r\n    .ThenInclude(d=>d.Logo)\r\n    .Select(g=> new { g.Title, g.GameId })\r\n    .ToListAsync();\r\n```\r\n<hr>\r\nthis query throws:\r\n`InvalidOperationException: Operation is not valid due to the current state of the object.\r\nGetArgument`\r\n```\r\nvar query3 = await context.Games\r\n    .Include(g=>g.Details)\r\n    .ThenInclude(d=>d.Logo)\r\n    .DefaultIfEmpty()\r\n    .Select(g=> new {  Logo = g.Details.Logo, g.Title, g.GameId })\r\n    .ToListAsync();\r\n```\r\n<hr>\r\nthis query throws:\r\n```SqlException: The column prefix 't10' does not match with a table name or alias name used in the query.\r\nNo column name was specified for column 1 of 't2'.\r\nInvalid column name 'Title'.\r\nInvalid column name 'GameId'.```\r\n\r\n```\r\n var query4 = await context.Games\r\n    .Include(g=>g.Details)\r\n    .ThenInclude(d=>d.Logo)\r\n    .DefaultIfEmpty()\r\n    .Select(g=> new { Logo = (GameFile)null, g.Title, g.GameId })\r\n    .ToListAsync();\r\n```\r\n<hr>\r\nthis query returns 4 elements, same as query2. (logo is explicit set as null):\r\n```\r\nvar query5 = await context.Games\r\n    .Include(g=>g.Details)\r\n    .ThenInclude(d=>d.Logo)\r\n    .Select(g=> new { Logo = (GameFile)null, g.Title, g.GameId })\r\n    .ToListAsync();\r\n```\r\n<hr>\r\nnote: using `g.Details?.Logo` on lambda does not compile."},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/235559547","html_url":"https://github.com/aspnet/EntityFramework/issues/6177#issuecomment-235559547","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6177","id":235559547,"user":{"login":"Bartmax","id":3386797,"avatar_url":"https://avatars.githubusercontent.com/u/3386797?v=3","gravatar_id":"","url":"https://api.github.com/users/Bartmax","html_url":"https://github.com/Bartmax","followers_url":"https://api.github.com/users/Bartmax/followers","following_url":"https://api.github.com/users/Bartmax/following{/other_user}","gists_url":"https://api.github.com/users/Bartmax/gists{/gist_id}","starred_url":"https://api.github.com/users/Bartmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bartmax/subscriptions","organizations_url":"https://api.github.com/users/Bartmax/orgs","repos_url":"https://api.github.com/users/Bartmax/repos","events_url":"https://api.github.com/users/Bartmax/events{/privacy}","received_events_url":"https://api.github.com/users/Bartmax/received_events","type":"User","site_admin":false},"created_at":"2016-07-27T11:32:07Z","updated_at":"2016-07-27T11:32:07Z","body":"I'm pretty sure the problem lies in that when specifying the navigation inside the `Select` the query switches from `LEFT JOIN` to `JOIN` hence my attempt to use `DefaultIfEmpty`."}}
{"actor":{"display_login":"Bartmax"}}