Skip to content

Instantly share code, notes, and snippets.

@jfbueno
Last active July 18, 2019 19:54
Show Gist options
  • Save jfbueno/a5ce6743c8a4707782ccc04b29326898 to your computer and use it in GitHub Desktop.
Save jfbueno/a5ce6743c8a4707782ccc04b29326898 to your computer and use it in GitHub Desktop.
IEnumerable<IGrouping<string, Compra>> grupos
= Compras.GroupBy(x => x.Cliente); // Como deve ser agrupado
foreach(var grupo in grupos) // Coleção de grupos
{
WriteLine($"Compras de {grupo.Key}");
foreach(var compra in grupo) // Compras do grupo => IGrouping<string, Compra>
{
WriteLine($"\t {compra.Valor:n2}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment