1
How could I be selecting the next record within a foreach
grouped before it ends, without advancing on that loop?
The point where I think I might be getting this information is where it’s written GET NEXT FOREACH ID 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>
I don’t know if I understand what you want, but at the end of the ribbon will come the next
id
. Do you want the next one before you finish? Wouldn’t it be better to put the LINQ on controller, in view should have only code strictly necessary to generate the view, this LINQ code is system rules, or even I would say business rule, which should be in the model.– Maniero
Exactly. I’d like to get the next one before I finish. Yes. agree and should LINQ be in the controller, but a problem arose and I had to implement so.
– Elton