I have this code in my controller:
var taxes = db.invoiceTaxes
.Where(c => c.invoiceId == invoice.invoiceId)
.GroupBy(row => new { row.TaxId, row.tax, row.percent, row.type })
.Select(group => new { tax = group.Key.tax, percent = group.Key.percent, sum = group.Sum(s => s.sum), type = group.Key.type });
ViewBag.taxes = taxes.ToList();
If I have this in my view
@foreach (var item in ViewBag.taxes)
{
@item
}
I get
{ tax = Facturacion.Models.Tax, percent = 16, sum = 31.36, type = False }
But when I have
@foreach (var item in ViewBag.taxes)
{
@item.percent
}
I get
Object does not contain a definition for percent
How can I show the fields my query returns? (In this case, the value "16")
invoiceTaxes is not my model, it's Invoice