How could I be selecting the next record within a grouped foreach
before it ends, without advancing in that loop ?
The point where I think I might be getting this information is where GET THE NEXT ID DESSE FOREACH is written in the code below:
decimal? valor = 0;
@foreach (var item in Model.Lista.GroupBy(d => d.Nome)
.Select(
g => new
{
key = g.Key,
Id = g.First().Id,
NomeFantasia = g.First().NomeFantasia,
ValorTotal = g.Sum(s => s.ValorTotal) }))
{
<tr>
<td>Id</td>
<td>Nome</td>
<td>Valor</td>
</tr>
valor += item.Valor;
<!- **OBTER O PRÓXIMO ID DESSE FOREACH** -->
}
<tr>
<td colspan="2"></td>
<td>@Valor</td>
</tr>