I managed to successfully return the model to the view and display the results in a strongly typed form.
I have never seen an example when several models return. How can I do it?
I assume the controller will have something like this:
return View(lemondb.Messages.Where(p => p.user == tmp_username).ToList(), lemondb.Lemons.Where(p => p.acidity >= 2).ToList());
Does MVC allow multiple models to be returned?
And then in the view, I have this line at the top of the file:
@model IEnumerable<ElkDogTrader.Models.Message>
And I often call the "model" in the view.
@foreach (var item in Model)
If there were 2 models, how would I address them separately?
Is this possible with multiple models, or is that why people use ViewBag and ViewData?
asp.net-mvc asp.net-mvc-3 entity-framework
micahhoover
source share