{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5958","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5958/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5958/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5958/events","html_url":"https://github.com/aspnet/EntityFramework/issues/5958","id":163525487,"number":5958,"title":"Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory:Error: An exception occurred in the database while iterating the results of a query.","user":{"login":"TerraVenil","id":6068068,"avatar_url":"https://avatars.githubusercontent.com/u/6068068?v=3","gravatar_id":"","url":"https://api.github.com/users/TerraVenil","html_url":"https://github.com/TerraVenil","followers_url":"https://api.github.com/users/TerraVenil/followers","following_url":"https://api.github.com/users/TerraVenil/following{/other_user}","gists_url":"https://api.github.com/users/TerraVenil/gists{/gist_id}","starred_url":"https://api.github.com/users/TerraVenil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TerraVenil/subscriptions","organizations_url":"https://api.github.com/users/TerraVenil/orgs","repos_url":"https://api.github.com/users/TerraVenil/repos","events_url":"https://api.github.com/users/TerraVenil/events{/privacy}","received_events_url":"https://api.github.com/users/TerraVenil/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-02T16:26:26Z","updated_at":"2016-07-06T07:47:55Z","closed_at":null,"body":"### Steps to reproduce\r\nStartup configuration\r\n`var connection = @\"Server=(localdb)\\mssqllocaldb;Database=Northwind;Trusted_Connection=True;\";\r\n            services.AddDbContext<OrderContext>(options => options.UseSqlServer(connection));`\r\n\r\nI have a very simple query in my Api\r\n```\r\n[HttpGet]\r\npublic IActionResult Get()\r\n{\r\n\tIEnumerable<Order> orders = _orderContext.Orders;\r\n\r\n\tvar result = orders\r\n\t\t.Where(x => x.OrderDate < new DateTime(1996, 7, 12) && x.OrderDate > new DateTime(1996, 7, 4))\r\n\t\t.OrderBy(x => x.ShippedDate)\r\n\t\t.GroupBy(x => x.ShipName);\r\n\r\n\treturn Ok(result);\r\n}       \r\n```\r\n\r\n### The issue\r\nI expected to load all orders from database and apply filtering on the Web Api side.\r\n```\r\nStack trace:\r\n```\r\nMicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory:Debug: TRACKED: True\r\n(QueryContext queryContext) => IEnumerable<Order> _ShapedQuery(\r\n    queryContext: queryContext, \r\n    shaperCommandContext: SelectExpression: \r\n        SELECT [o].[OrderID], [o].[OrderDate], [o].[ShipName], [o].[ShippedDate]\r\n        FROM [Orders] AS [o]\r\n    , \r\n    shaper: UnbufferedEntityShaper<Order>\r\n)\r\n\r\n'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\\Users\\USER_NAME\\.nuget\\packages\\System.Data.SqlClient\\4.1.0\\runtimes\\win\\lib\\netstandard1.3\\System.Data.SqlClient.dll'. Cannot find or open the PDB file.\r\nMicrosoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection:Debug: Opening connection to database 'Northwind' on server '(localdb)\\mssqllocaldb'.\r\n'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\1.0.0\\System.Text.Encoding.CodePages.dll'. Cannot find or open the PDB file.\r\n'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\1.0.0\\Microsoft.Win32.Primitives.dll'. Cannot find or open the PDB file.\r\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory:Information: Executed DbCommand (10ms) [Parameters=[], CommandType='Text', CommandTimeout='30']\r\nSELECT [o].[OrderID], [o].[OrderDate], [o].[ShipName], [o].[ShippedDate]\r\nFROM [Orders] AS [o]\r\nException thrown: 'System.NullReferenceException' in Microsoft.EntityFrameworkCore.Relational.dll\r\nMicrosoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection:Debug: Closing connection to database 'Northwind' on server '(localdb)\\mssqllocaldb'.\r\nMicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory:Error: An exception occurred in the database while iterating the results of a query.\r\nSystem.NullReferenceException: Object reference not set to an instance of an object.\r\n   at lambda_method(Closure , ValueBuffer )\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.UnbufferedEntityShaper`1.Shape(QueryContext queryContext, ValueBuffer valueBuffer)\r\n   at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__15`2.MoveNext()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()\r\n\r\nSystem.NullReferenceException: Object reference not set to an instance of an object.\r\n   at lambda_method(Closure , ValueBuffer )\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.UnbufferedEntityShaper`1.Shape(QueryContext queryContext, ValueBuffer valueBuffer)\r\n   at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__15`2.MoveNext()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()\r\nException thrown: 'System.NullReferenceException' in Microsoft.EntityFrameworkCore.dll\r\nException thrown: 'System.NullReferenceException' in Newtonsoft.Json.dll\r\nException thrown: 'System.NullReferenceException' in System.Private.CoreLib.ni.dll\r\n\r\nAdditional strange line of debug information\r\n```\r\nMicrosoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory:Warning: The LINQ expression 'GroupBy([x].ShipName, [x])' 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\n```\r\n### Further technical details\r\n\r\n\"Microsoft.EntityFrameworkCore\": \"1.0.0\",\r\n\"Microsoft.EntityFrameworkCore.SqlServer\": \"1.0.0\"\r\n\r\nOperating system:\r\nWindows 7\r\nVisual Studio version: VS 2015 Update 3"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/230701870","html_url":"https://github.com/aspnet/EntityFramework/issues/5958#issuecomment-230701870","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5958","id":230701870,"user":{"login":"TerraVenil","id":6068068,"avatar_url":"https://avatars.githubusercontent.com/u/6068068?v=3","gravatar_id":"","url":"https://api.github.com/users/TerraVenil","html_url":"https://github.com/TerraVenil","followers_url":"https://api.github.com/users/TerraVenil/followers","following_url":"https://api.github.com/users/TerraVenil/following{/other_user}","gists_url":"https://api.github.com/users/TerraVenil/gists{/gist_id}","starred_url":"https://api.github.com/users/TerraVenil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TerraVenil/subscriptions","organizations_url":"https://api.github.com/users/TerraVenil/orgs","repos_url":"https://api.github.com/users/TerraVenil/repos","events_url":"https://api.github.com/users/TerraVenil/events{/privacy}","received_events_url":"https://api.github.com/users/TerraVenil/received_events","type":"User","site_admin":false},"created_at":"2016-07-06T07:47:55Z","updated_at":"2016-07-06T07:47:55Z","body":"Nope, it's not related to null value for `ShipName` anyway it should not throw an exception :)\r\nFor example, if you are using query like that\r\n```\r\nIQuerable<Order> orders = _orderContext.Orders;\r\n\r\nvar result = orders\r\n        .Where(x => x.OrderDate < new DateTime(1996, 7, 12) && x.OrderDate > new DateTime(1996, 7, 4))\r\n        .OrderBy(x => x.ShippedDate)\r\n        .GroupBy(x => x.ShipName);\r\n\r\n    return Ok(result);\r\n```\r\n\r\nit works perfect! So I think it's problem between difference `IEnumerable<T>` and `IQuerable<T>` interfaces.\r\n"}}
{"actor":{"display_login":"TerraVenil"}}