I\'ve seen many questions about this, but i\'ve never really got the answer that I need.
I\'m converting a fairly large web application from Web Forms to MVC and af
Rather than an anonymous type, create a type to hold the name and date:
public class NameDate
{
public string Name { get; set; }
public DateTime Date { get; set; }
}
Then use that in your Linq query:
from p in db.Products select new NameDate { Name = p.Name, Date = p.Date }
Strongly type your view to be MyView
and then just do a foreach ( var nameDate in ViewData.Model )...