{"action":"closed","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/2320","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/2320/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/2320/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/2320/events","html_url":"https://github.com/aspnet/EntityFramework/issues/2320","id":84706158,"number":2320,"title":"Subqueries are executed for each result in the outer query","user":{"login":"mikary","id":6787717,"avatar_url":"https://avatars.githubusercontent.com/u/6787717?v=3","gravatar_id":"","url":"https://api.github.com/users/mikary","html_url":"https://github.com/mikary","followers_url":"https://api.github.com/users/mikary/followers","following_url":"https://api.github.com/users/mikary/following{/other_user}","gists_url":"https://api.github.com/users/mikary/gists{/gist_id}","starred_url":"https://api.github.com/users/mikary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikary/subscriptions","organizations_url":"https://api.github.com/users/mikary/orgs","repos_url":"https://api.github.com/users/mikary/repos","events_url":"https://api.github.com/users/mikary/events{/privacy}","received_events_url":"https://api.github.com/users/mikary/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-03T18:29:33Z","updated_at":"2015-06-03T18:37:34Z","closed_at":"2015-06-03T18:37:34Z","body":"```QueryTestBase``` contains the following test definition:\r\n\r\n```cs\r\n[Fact]\r\npublic virtual void Contains_with_subquery()\r\n{\r\n    AssertQuery<Customer, Order>((cs, os) =>\r\n        cs.Where(c => os.Select(o => o.CustomerID).Contains(c.CustomerID)));\r\n}\r\n```\r\nExecuting this test by overriding on ```QuerySqlServerTest``` results in execution of the following SQL (with the subquery repeated for each record in the outer query):\r\n\r\n```sql\r\nSELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]\r\nFROM [Customers] AS [c]\r\n\r\nSELECT [o].[CustomerID]\r\nFROM [Orders] AS [o]\r\n\r\nSELECT [o].[CustomerID]\r\nFROM [Orders] AS [o]\r\n\r\nSELECT [o].[CustomerID]\r\nFROM [Orders] AS [o]\r\n...\r\n```"}}