Created
February 5, 2015 20:17
-
-
Save AlexArchive/258149b64ced1527a55b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lookup = new Dictionary<int, Artist>(); | |
IEnumerable<Artist> foo = | |
connection.Query<Artist, Record, Artist>( | |
"SELECT * FROM dbo.Artists INNER JOIN dbo.Records ON dbo.Records.artistId = dbo.Artists.id", | |
(a, r) => | |
{ | |
Artist artist; | |
if (!lookup.TryGetValue(a.Id, out artist)) | |
{ | |
lookup.Add(a.Id, artist = a); | |
} | |
if (artist.Records == null) | |
{ | |
artist.Records = new List<Record>(); | |
} | |
artist.Records.Add(r); | |
return artist; | |
}); | |
var result = lookup.Values; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment