Skip to content

Instantly share code, notes, and snippets.

@smiler
Created October 26, 2012 07:35
Show Gist options
  • Save smiler/3957435 to your computer and use it in GitHub Desktop.
Save smiler/3957435 to your computer and use it in GitHub Desktop.
var loltable = new[] {
new { Property = "Name", Value = "Glenn", Id = 7 },
new { Property = "LastName", Value = "Brax", Id = 7 },
new { Property = "Active", Value = "1", Id = 7 },
new { Property = "Name", Value = "Kossa", Id = 5 },
new { Property = "LastName", Value = "Mu", Id = 5 },
new { Property = "Active", Value = "0", Id = 5 },
new { Property = "Name", Value = "Trololol", Id = 2 },
new { Property = "LastName", Value = "Håhåhå", Id = 2 },
new { Property = "Active", Value = "1", Id = 2 }
};
var lol = from lol in loltable
group lol by lol.Id into lolGroups
select new {
Id = lolGroups.Key,
Name = lolGroups.First (g => g.Property == "Name").Value,
LastName = lolGroups.First (g => g.Property == "LastName").Value,
Active = lolGroups.First (g => g.Property == "Active").Value
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment