{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/1645","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/1645/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/1645/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/1645/events","html_url":"https://github.com/aspnet/EntityFramework/issues/1645","id":58067243,"number":1645,"title":"Some SQL filters don't get evaluated in a where linq chain.","user":{"login":"ztone","id":3028306,"avatar_url":"https://avatars.githubusercontent.com/u/3028306?v=3","gravatar_id":"","url":"https://api.github.com/users/ztone","html_url":"https://github.com/ztone","followers_url":"https://api.github.com/users/ztone/followers","following_url":"https://api.github.com/users/ztone/following{/other_user}","gists_url":"https://api.github.com/users/ztone/gists{/gist_id}","starred_url":"https://api.github.com/users/ztone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ztone/subscriptions","organizations_url":"https://api.github.com/users/ztone/orgs","repos_url":"https://api.github.com/users/ztone/repos","events_url":"https://api.github.com/users/ztone/events{/privacy}","received_events_url":"https://api.github.com/users/ztone/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/pri0","name":"pri0","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"maumar","id":1591930,"avatar_url":"https://avatars.githubusercontent.com/u/1591930?v=3","gravatar_id":"","url":"https://api.github.com/users/maumar","html_url":"https://github.com/maumar","followers_url":"https://api.github.com/users/maumar/followers","following_url":"https://api.github.com/users/maumar/following{/other_user}","gists_url":"https://api.github.com/users/maumar/gists{/gist_id}","starred_url":"https://api.github.com/users/maumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maumar/subscriptions","organizations_url":"https://api.github.com/users/maumar/orgs","repos_url":"https://api.github.com/users/maumar/repos","events_url":"https://api.github.com/users/maumar/events{/privacy}","received_events_url":"https://api.github.com/users/maumar/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/7","html_url":"https://github.com/aspnet/EntityFramework/milestones/7.0.0","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/7/labels","id":666128,"number":7,"title":"7.0.0","description":"","creator":{"login":"rowanmiller","id":4741851,"avatar_url":"https://avatars.githubusercontent.com/u/4741851?v=3","gravatar_id":"","url":"https://api.github.com/users/rowanmiller","html_url":"https://github.com/rowanmiller","followers_url":"https://api.github.com/users/rowanmiller/followers","following_url":"https://api.github.com/users/rowanmiller/following{/other_user}","gists_url":"https://api.github.com/users/rowanmiller/gists{/gist_id}","starred_url":"https://api.github.com/users/rowanmiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rowanmiller/subscriptions","organizations_url":"https://api.github.com/users/rowanmiller/orgs","repos_url":"https://api.github.com/users/rowanmiller/repos","events_url":"https://api.github.com/users/rowanmiller/events{/privacy}","received_events_url":"https://api.github.com/users/rowanmiller/received_events","type":"User","site_admin":false},"open_issues":165,"closed_issues":168,"state":"open","created_at":"2014-05-21T19:25:32Z","updated_at":"2015-03-04T17:17:42Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2015-02-18T13:27:03Z","updated_at":"2015-03-04T18:35:13Z","closed_at":"2015-03-03T01:30:39Z","body":"I might be missing something but I was just trying out EF7 and found something unexpected.\r\n\r\nSo this works\r\n```c#\r\nusing (var ctx = new Context())\r\n{\r\n\tvar query = ctx.Data.Where(x => x.Date >= start && x.Date <= end && x.Excluded.Equals(true));\r\n\tvar c = query.Count(); \r\n}\r\n```\r\nAnd get the expected SQl\r\n```sql\r\nexec sp_executesql N'SELECT COUNT(*)\r\nFROM [Data] AS [x]\r\nWHERE (([x].[Date] >= @p0 AND [x].[Date] <= @p0) AND [x].[Excluded] = @p1)',N'@p0 datetime,@p1 bit',@p0='2014-01-01 00:00:00',@p1=1\r\n```\r\n\r\nHowever chaining the filters ...\r\n```c#\r\nusing (var ctx = new Context())\r\n{\r\n\tvar query = ctx.Data.Where(x => x.Date >= start && x.Date <= end);\r\n\tquery = query.Where(x => x.Excluded.Equals(true));\r\n\tvar c = query.Count(); \r\n}\r\n```\r\n\r\n... seems to overwrite the preceeding filters as only the last filter was evaluated in the SQL\r\n```sql\r\nexec sp_executesql N'SELECT COUNT(*)\r\nFROM [Data] AS [x]\r\nWHERE [x].[Excluded] = @p0',N'@p0 bit',@p0=1\r\n```\r\n\r\nThe expression for reference\r\n>{value(Microsoft.Data.Entity.Query.EntityQueryable`1[Company.DataAccess.Models.Data]).Where(x => ((x.Date >= Convert(value(Company.DataAccess.Services.Service+<>c__DisplayClass0).start)) AndAlso (x.Date <= Convert(value(Company.DataAccess.Services.Service+<>c__DisplayClass0).end)))).Where(x => x.Excluded.Equals(True))}\r\n\r\n\r\nUsing VS2015 Preview ASP 5 \r\ndep : \"EntityFramework\": \"7.0.0-beta1\"\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/77217078","html_url":"https://github.com/aspnet/EntityFramework/issues/1645#issuecomment-77217078","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/1645","id":77217078,"user":{"login":"maumar","id":1591930,"avatar_url":"https://avatars.githubusercontent.com/u/1591930?v=3","gravatar_id":"","url":"https://api.github.com/users/maumar","html_url":"https://github.com/maumar","followers_url":"https://api.github.com/users/maumar/followers","following_url":"https://api.github.com/users/maumar/following{/other_user}","gists_url":"https://api.github.com/users/maumar/gists{/gist_id}","starred_url":"https://api.github.com/users/maumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maumar/subscriptions","organizations_url":"https://api.github.com/users/maumar/orgs","repos_url":"https://api.github.com/users/maumar/repos","events_url":"https://api.github.com/users/maumar/events{/privacy}","received_events_url":"https://api.github.com/users/maumar/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T18:35:13Z","updated_at":"2015-03-04T18:35:13Z","body":"This should be checked in today."}}