{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6276","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6276/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6276/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6276/events","html_url":"https://github.com/aspnet/EntityFramework/issues/6276","id":170226464,"number":6276,"title":"NullReferenceException in big query?","user":{"login":"kierepka","id":344056,"avatar_url":"https://avatars.githubusercontent.com/u/344056?v=3","gravatar_id":"","url":"https://api.github.com/users/kierepka","html_url":"https://github.com/kierepka","followers_url":"https://api.github.com/users/kierepka/followers","following_url":"https://api.github.com/users/kierepka/following{/other_user}","gists_url":"https://api.github.com/users/kierepka/gists{/gist_id}","starred_url":"https://api.github.com/users/kierepka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kierepka/subscriptions","organizations_url":"https://api.github.com/users/kierepka/orgs","repos_url":"https://api.github.com/users/kierepka/repos","events_url":"https://api.github.com/users/kierepka/events{/privacy}","received_events_url":"https://api.github.com/users/kierepka/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/type-bug","name":"type-bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/type-enhancement","name":"type-enhancement","color":"bfe5bf"}],"state":"open","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},"assignees":[{"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/19","html_url":"https://github.com/aspnet/EntityFramework/milestones/1.1.0","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/19/labels","id":1748298,"number":19,"title":"1.1.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":116,"closed_issues":130,"state":"open","created_at":"2016-05-04T18:23:47Z","updated_at":"2016-08-16T18:06:08Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2016-08-09T17:38:29Z","updated_at":"2016-08-17T03:30:04Z","closed_at":null,"body":"### Steps to reproduce\r\nCreate big query with subqueries give NullReferenceException. Sample below\r\n### The issue\r\nQuite big linq query is working ok on EF6 but EFCore give NullReferenceException\r\n``` C#\r\nq =  (from d in db.Doctors\r\nfrom dpm in d.DoctorPatientMaps\r\njoin p in db.Patients on dpm.PatientId equals p.Id\r\njoin r in db.Readings on p.Id equals r.PatientId\r\njoin o in db.Orders on r.Id equals o.ReadingId into lor\r\nfrom os in lor.DefaultIfEmpty()\r\njoin m in db.MedicalFacilities on os.MedicalFacilityId equals m.Id into lms\r\nfrom ms in lms.DefaultIfEmpty()\r\njoin rd in db.ReadingDescriptions on r.Id equals rd.ReadingId into lrds\r\nfrom rds in lrds.DefaultIfEmpty()\r\norderby r.LastUpdateDate descending\r\nwhere d.Id == doctorId.Value && (includeEmergency ? (!r.IsEmergency || r.IsEmergency == d.CanSeeEmergency) : !r.IsEmergency)\r\n            && (!r.IsDemo || r.IsDemo == d.CanSeeDemo)\r\nselect new\r\n{\r\n    Id = r.Id,\r\n    ReadingAddDate = r.ReadingAddDate,\r\n    ReadingStartDate = r.ReadingStartDate,\r\n    ReadingEndDate = r.ReadingEndDate,\r\n    PatientId = r.PatientId,\r\n    DataPath = r.DataPath,\r\n    ExamFileName = r.ExamFileName,\r\n    Type = r.Type,\r\n    Status = r.Status,\r\n    Comment = r.Comment,\r\n    PaperOffsetSpeed = r.PaperOffsetSpeed,\r\n    Gain = r.Gain,\r\n    DeviceId = r.DeviceId,\r\n    CanBeChanged = r.CanBeChanged,\r\n    DoctorIdInExam = r.DoctorIdInExam,\r\n    Data = r.Data,\r\n    LastUpdateDate = r.LastUpdateDate,\r\n    IsEmergency = r.IsEmergency,\r\n    PreinterpretedRecognition = r.PreinterpretedRecognition,\r\n    DoctorUuid = r.DoctorUuid,\r\n    IsProcessed = r.IsProcessed,\r\n    VersionOfTheAlgorithm = r.VersionOfTheAlgorithm,\r\n    SourceFilename = r.SourceFilename,\r\n    IsSentToDescription = r.IsSentToDescription,\r\n    Mood = r.Mood,\r\n    SampleRate = r.SampleRate,\r\n    ReadingRootId = r.ReadingRootId,\r\n    EndDescriptionDate = r.EndDescriptionDate,\r\n    IsContainsAnyRaport = r.IsContainsAnyRaport,\r\n    IsDemo = r.IsDemo,\r\n    IsCanceled = r.IsCanceled,\r\n    IsDeleted = r.IsDeleted,\r\n    ApplicationVersion = r.ApplicationVersion,\r\n    ReadingTypeId = r.ReadingTypeId,\r\n    OrderId = (int?)os.Id,\r\n    OrderDateTime = (DateTime?)os.DateTime,\r\n    OrderMaxDescriptionTime = (int?)os.MaxDescriptionTime,\r\n    OrderMedicalFacilityName = ms.Name,\r\n    MedicalFacilityId = (int?)ms.Id,\r\n    IsDescribed = ((int?)rds.Id).HasValue,\r\n    IsAllEventsAreConfirmed = (from rres in db.ReadingEvents\r\n                                where rres.Status == \"NP\" && rres.ReadingId == r.Id\r\n                                select rres.Id).Count() == 0,\r\n    IsRootToOrders = (from r3 in db.Readings\r\n                        where r3.ReadingRootId == r.Id\r\n                        select r3.Id).Count() != 0\r\n\r\n});\r\n```\r\n\r\nException message:\r\n> System.NullReferenceException was unhandled by user code\r\n  HResult=-2147467261\r\n  Message=Object reference not set to an instance of an object.\r\n  Source=Anonymously Hosted DynamicMethods Assembly\r\n  StackTrace:\r\n       at lambda_method(Closure , TransparentIdentifier`2 )\r\n       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n       at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()\r\n       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n      \r\n### Further technical details\r\n\r\nEF Core version: version=\"1.0.0\"\r\nOperating system: Windows 10/Server\r\nVisual Studio version: VS 2015\r\n\r\nOther details about my project setup: IIS ASP.NET Web"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/240304360","html_url":"https://github.com/aspnet/EntityFramework/issues/6276#issuecomment-240304360","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6276","id":240304360,"user":{"login":"jjanne","id":11335586,"avatar_url":"https://avatars.githubusercontent.com/u/11335586?v=3","gravatar_id":"","url":"https://api.github.com/users/jjanne","html_url":"https://github.com/jjanne","followers_url":"https://api.github.com/users/jjanne/followers","following_url":"https://api.github.com/users/jjanne/following{/other_user}","gists_url":"https://api.github.com/users/jjanne/gists{/gist_id}","starred_url":"https://api.github.com/users/jjanne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjanne/subscriptions","organizations_url":"https://api.github.com/users/jjanne/orgs","repos_url":"https://api.github.com/users/jjanne/repos","events_url":"https://api.github.com/users/jjanne/events{/privacy}","received_events_url":"https://api.github.com/users/jjanne/received_events","type":"User","site_admin":false},"created_at":"2016-08-17T03:30:04Z","updated_at":"2016-08-17T03:30:04Z","body":"Hello, \r\nWhen is this issue going to be resolved?"}}
{"actor":{"display_login":"jjanne"}}