Skip to content

Instantly share code, notes, and snippets.

@jfbueno
Last active July 18, 2019 19:54
Show Gist options
  • Save jfbueno/2e2a7ab9850b6d9f7d8bd3f74ab6e47e to your computer and use it in GitHub Desktop.
Save jfbueno/2e2a7ab9850b6d9f7d8bd3f74ab6e47e to your computer and use it in GitHub Desktop.
IEnumerable<IGrouping<int, Compra>> grupos
= Compras.GroupBy(compra => compra.Pagamento.Month); // Como deve ser agrupado
foreach(var grupo in grupos) // Coleção de grupos
{
WriteLine($"Compras pagas no mês de {_dtFormat.GetMonthName(grupo.Key)}"); // Chave do agrupamento
foreach(var elemento in grupo) // Compras do grupo => IGrouping<int, Compra>
{
WriteLine($"\t{elemento.ToString()}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment