{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6517","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6517/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6517/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6517/events","html_url":"https://github.com/aspnet/EntityFramework/issues/6517","id":176601606,"number":6517,"title":"EF doesn't map queries to SQL... at all :(","user":{"login":"cbmek","id":1478006,"avatar_url":"https://avatars.githubusercontent.com/u/1478006?v=3","gravatar_id":"","url":"https://api.github.com/users/cbmek","html_url":"https://github.com/cbmek","followers_url":"https://api.github.com/users/cbmek/followers","following_url":"https://api.github.com/users/cbmek/following{/other_user}","gists_url":"https://api.github.com/users/cbmek/gists{/gist_id}","starred_url":"https://api.github.com/users/cbmek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbmek/subscriptions","organizations_url":"https://api.github.com/users/cbmek/orgs","repos_url":"https://api.github.com/users/cbmek/repos","events_url":"https://api.github.com/users/cbmek/events{/privacy}","received_events_url":"https://api.github.com/users/cbmek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-13T10:11:30Z","updated_at":"2016-09-14T07:00:01Z","closed_at":null,"body":"### The issue\r\nIt seams that EF (`\"Microsoft.EntityFrameworkCore.SqlServer\": \"1.0.0\"`) doesn't translate lambda expressions to SQL in my case, and does everything \"in memory\".\r\nThis code below is the same code I've been using in `7.0.0-rc1-final` and it used to utilize SQL queries:\r\n\r\n``` C# \r\nint c = _context.Participants.Count(); // count all\r\nIQueryable<Participant> tmp = null;\r\nstring sr = \"meme\";\r\ntmp = _context.Participants.Where(m => m.FirstName.Contains(sr) || m.LastName.Contains(sr));\r\ntmp = tmp.OrderBy(m => m.LastName);\r\nint fc = tmp.Count(); // count filtered\r\n\r\nvar resp = (await tmp.Skip(start).Take(length).ToListAsync()).Select(m => new ParticipantView()\r\n{\r\n  Id = m.Id,\r\n  FirstName = m.FirstName,\r\n  LastName = m.LastName\r\n});\r\n```\r\n\r\nI expect it to do 3 queries:\r\n1) count all\r\n2) count filtered\r\n3) select filtered and paged\r\n...and it does execute 3 queries but they look like this:\r\n\r\n1) `SELECT COUNT(*) FROM [Participants] AS [p]` // this one look ok\r\n2) `SELECT [m].[Id], [m].[About], [m].[EmailAddress], [m].[FirstName], [m].[LastName], [m].[PhoneNumber] FROM [Participants] AS [m]` // this should do the count I guess, but if fetches all rows and cont in memory. It also should be filtered already.\r\n3) `SELECT [m].[Id], [m].[About], [m].[EmailAddress], [m].[FirstName], [m].[LastName], [m].[PhoneNumber] FROM [Participants] AS [m] ORDER BY [m].[LastName]` // this should be filtered and paged. It again does filtering in memory.\r\n\r\nAm I doing something wrong, or is there something wrong with `1.0.0` version?"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/246923636","html_url":"https://github.com/aspnet/EntityFramework/issues/6517#issuecomment-246923636","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6517","id":246923636,"user":{"login":"cbmek","id":1478006,"avatar_url":"https://avatars.githubusercontent.com/u/1478006?v=3","gravatar_id":"","url":"https://api.github.com/users/cbmek","html_url":"https://github.com/cbmek","followers_url":"https://api.github.com/users/cbmek/followers","following_url":"https://api.github.com/users/cbmek/following{/other_user}","gists_url":"https://api.github.com/users/cbmek/gists{/gist_id}","starred_url":"https://api.github.com/users/cbmek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbmek/subscriptions","organizations_url":"https://api.github.com/users/cbmek/orgs","repos_url":"https://api.github.com/users/cbmek/repos","events_url":"https://api.github.com/users/cbmek/events{/privacy}","received_events_url":"https://api.github.com/users/cbmek/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T07:00:01Z","updated_at":"2016-09-14T07:00:01Z","body":"Hi, I've just found out that it's not due to `.Contains()` in query but the other part I removed in my example... because I didn't expect it to break the query. Here is my full query and below the console log from debug. When I remove the last condition it generetes good SQL query with COUNT/WHERE and pageing.\r\n\r\nIt seams that string formatiing is not applied and EF doesn't know what to do with query.\r\n\r\n```csharp\r\ntmp = _context.Participants.Where(m => m.FirstName.ToLower().Contains(sr) || m.LastName.ToLower().Contains(sr) || $\"#{m.Id}\" == sr);\r\n```\r\n\r\n```\r\nicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory: Warning: The LINQ expression '(([m].FirstName.ToLower().Contains(__sr_0) OrElse [m].LastName.ToLower().Contains(__sr_1)) OrElse (Format(\"#{0}\", Convert([m].Id)) == __sr_2))' could not be translated and will be evaluated locally. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'RelationalEventId.QueryClientEvaluationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.\r\nMicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory: Warning: The LINQ expression 'Count()' could not be translated and will be evaluated locally. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'RelationalEventId.QueryClientEvaluationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.\r\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory: Information: Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']\r\nSELECT [m].[Id], [m].[About], [m].[EmailAddress], [m].[FirstName], [m].[LastName], [m].[PhoneNumber]\r\nFROM [Participants] AS [m]\r\nMicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory: Warning: The LINQ expression '(([m].FirstName.ToLower().Contains(__sr_0) OrElse [m].LastName.ToLower().Contains(__sr_1)) OrElse (Format(\"#{0}\", Convert([m].Id)) == __sr_2))' could not be translated and will be evaluated locally. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'RelationalEventId.QueryClientEvaluationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.\r\nMicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory: Warning: The LINQ expression 'Skip(__p_3)' could not be translated and will be evaluated locally. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'RelationalEventId.QueryClientEvaluationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.\r\nMicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory: Warning: The LINQ expression 'Take(__p_4)' could not be translated and will be evaluated locally. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'RelationalEventId.QueryClientEvaluationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.\r\nThe thread 0x6368 has exited with code 0 (0x0).\r\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory: Information: Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']\r\nSELECT [m].[Id], [m].[About], [m].[EmailAddress], [m].[FirstName], [m].[LastName], [m].[PhoneNumber]\r\nFROM [Participants] AS [m]\r\nORDER BY [m].[LastName]\r\n```"}}
{"actor":{"display_login":"cbmek"}}