I found this piece of code in a scaffolded view in a C# project, but I don't really understand the syntax after the "List" part. Why do you declare a list of prices before writing ViewBag.data? Because the ViewBag.Data already contains a query with prices converted to a list so I don't understand why that happens
@foreach (var x in ((List<WebCashRegister.Models.BLModels.Price>)ViewBag.data).Where(x => x.ProductId == item.Id).OrderByDescending(x => x.StartDate).Take(1))
that's the complete query, but my question is only about this part:
List<WebCashRegister.Models.BLModels.Price>)ViewBag.data
how does this syntax work? Thanks!