{"action":"created","issue":{"url":"https://api.github.com/repos/jonwagner/Insight.Database/issues/238","labels_url":"https://api.github.com/repos/jonwagner/Insight.Database/issues/238/labels{/name}","comments_url":"https://api.github.com/repos/jonwagner/Insight.Database/issues/238/comments","events_url":"https://api.github.com/repos/jonwagner/Insight.Database/issues/238/events","html_url":"https://github.com/jonwagner/Insight.Database/issues/238","id":121613575,"number":238,"title":"Child records not mapping ParentId even when the Id is on the object","user":{"login":"elexisvenator","id":2984373,"avatar_url":"https://avatars.githubusercontent.com/u/2984373?v=3","gravatar_id":"","url":"https://api.github.com/users/elexisvenator","html_url":"https://github.com/elexisvenator","followers_url":"https://api.github.com/users/elexisvenator/followers","following_url":"https://api.github.com/users/elexisvenator/following{/other_user}","gists_url":"https://api.github.com/users/elexisvenator/gists{/gist_id}","starred_url":"https://api.github.com/users/elexisvenator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elexisvenator/subscriptions","organizations_url":"https://api.github.com/users/elexisvenator/orgs","repos_url":"https://api.github.com/users/elexisvenator/repos","events_url":"https://api.github.com/users/elexisvenator/events{/privacy}","received_events_url":"https://api.github.com/users/elexisvenator/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-11T01:11:56Z","updated_at":"2015-12-13T22:45:52Z","closed_at":null,"body":"So I have a rather simple query, which is almost identical to the one on the [Specifying Result Structures](https://github.com/jonwagner/Insight.Database/wiki/Specifying-Result-Structures) page:\r\n\r\n```\r\nCREATE PROC GetBeerAndGlasses AS\r\n    SELECT * FROM Beer\r\n    SELECT b.BeerID, g.* FROM Beer JOIN Glasses ON (...)\r\n\r\nclass Glass\r\n{\r\n    public int ID;\r\n    public int BeerID;\r\n}\r\n\r\nclass Beer\r\n{\r\n    public int ID;\r\n    public IList<Glass> Glasses;\r\n}\r\n\r\nvar results = connection.Query(\"GetBeerAndGlasses\", Parameters.Empty,\r\n    Query.Returns(Some<Beer>.Records)\r\n        .ThenChildren(Some<Glasses>.Records);\r\n```\r\n\r\nThe key difference from the wiki example is that `Glass` also has `BeerID` as a property. For our use, this is important because all Glasses belong to exactly one Beer, and we often look at Glass on its own without its matching Beer, so the object has BeerID on it. In this example BeerID never gets mapped, I would guess because Insight uses it for mapping to the parent object then discards the column.\r\n\r\nReproduced in SqlServer 2014 Standard, Insight 5.2.5"},"comment":{"url":"https://api.github.com/repos/jonwagner/Insight.Database/issues/comments/164307359","html_url":"https://github.com/jonwagner/Insight.Database/issues/238#issuecomment-164307359","issue_url":"https://api.github.com/repos/jonwagner/Insight.Database/issues/238","id":164307359,"user":{"login":"elexisvenator","id":2984373,"avatar_url":"https://avatars.githubusercontent.com/u/2984373?v=3","gravatar_id":"","url":"https://api.github.com/users/elexisvenator","html_url":"https://github.com/elexisvenator","followers_url":"https://api.github.com/users/elexisvenator/followers","following_url":"https://api.github.com/users/elexisvenator/following{/other_user}","gists_url":"https://api.github.com/users/elexisvenator/gists{/gist_id}","starred_url":"https://api.github.com/users/elexisvenator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elexisvenator/subscriptions","organizations_url":"https://api.github.com/users/elexisvenator/orgs","repos_url":"https://api.github.com/users/elexisvenator/repos","events_url":"https://api.github.com/users/elexisvenator/events{/privacy}","received_events_url":"https://api.github.com/users/elexisvenator/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T22:45:52Z","updated_at":"2015-12-13T22:45:52Z","body":"The workaround we have now is to do the following:\r\n\r\n```\r\nvar results = connection.Query(\"GetBeerAndGlasses\", Parameters.Empty,\r\n    Query.Returns(Some<Beer>.Records)\r\n        .ThenChildren(Some<Glasses>.Records.GroupBy(glass => glass.Id));\r\n```\r\n\r\nThis works, and your suggestions work as well, but:\r\n\r\n * I am working on a large codebase with an established convention for defining these kind of objects.\r\n * We do not like using ORM-specific attributes on objects that otherwise don't care about how they are accessed.\r\n * For Insight, it feels inconsistent for the Id to be mapped in almost every scenario.. except the simplest."}}