Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't display Viewmodel from EF
    primarykey
    data
    text
    <p>I'm trying to get a agrip on MVC3 but im failing on a Viewmodel which is supposed to display a List but constantly running into an dictionary error.</p> <blockquote> <p>The model item passed into the dictionary is of type "marc_bew_online.ViewModels.StellenlisteViewModel", but this dictionary requires a model item of type "System.Collections.Generic.IEnumerable`1[marc_bew_online.ViewModels.StellenlisteViewModel]".</p> </blockquote> <p>Here's the code to my repository:</p> <pre><code>public class Stellenbeschr_Repo : IStellenBeschrRepository { marc_bew_entities db = new marc_bew_entities(); public IEnumerable&lt;STELLENBESCHREIBUNGEN&gt; ListAktuell() { DateTime dt1 = new DateTime(2011, 1, 1); var stelleBeschreibungAbDatum = (from stellebeschreibung in db.STELLENBESCHREIBUNGEN where DateTime.Compare((DateTime)stellebeschreibung.VON_DATUM, dt1) &gt;= 0 select stellebeschreibung).ToList(); return stelleBeschreibungAbDatum; } } </code></pre> <p>Controller + ViewModel:</p> <pre><code> private IStellenBeschrRepository _repository; public Default1Controller() : this(new Stellenbeschr_Repo()) { } public Default1Controller(IStellenBeschrRepository repository) { _repository = repository; } #endregion public ActionResult Index() { return View(_repository.ListAktuell()); } public ActionResult Stellenliste() { var viewModels = new StellenlisteViewModel { StellenListe = _repository.ListAktuell() }; return View(viewModels); } public class StellenlisteViewModel { public IEnumerable&lt;STELLENBESCHREIBUNGEN&gt; StellenListe { get; set; } } </code></pre> <p>Viewpage extract:</p> <pre><code> @foreach(var item in Model.StellenListe) { &lt;tr&gt; &lt;td&gt; @Html.Display(item.STELLENBESCHREIBUNG); &lt;/td&gt; &lt;/tr&gt; } </code></pre> <p>The Viewpage is currently displaying ";" for every item the LINQ expression has found</p> <p>I just cant find a solution to get the list displayed in my view.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload