Skip to content

Instantly share code, notes, and snippets.

@jfbueno
Last active July 18, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfbueno/c8d33573416c5bf904d180da85b74c7b to your computer and use it in GitHub Desktop.
Save jfbueno/c8d33573416c5bf904d180da85b74c7b to your computer and use it in GitHub Desktop.
var agg = grupos.Select(gp => new
{
Cliente = gp.Key,
QuantidadeCompras = gp.Count(),
MelhorCompra = gp.Max(x => x.Valor),
PiorCompra = gp.Min(x => x.Valor),
TotalCompras = gp.Sum(x => x.Valor)
});
foreach(var elemento in agg)
{
WriteLine($"Cliente: {elemento.Cliente}");
WriteLine($"Quantidade de compras: {elemento.QuantidadeCompras}");
WriteLine($"Melhor Compra: {elemento.MelhorCompra}");
WriteLine($"Pior Compra: {elemento.PiorCompra}");
WriteLine($"Total em compras: {elemento.TotalCompras}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment