Note that there are some explanatory texts on larger screens.

plurals
  1. POmvc 3 - Model with multiple IEnumerable
    primarykey
    data
    text
    <p>I'm looking for the best approach to my problem. </p> <p>I need to display the names only of 3 different entities, not the rest of the information. </p> <p>Entities are:</p> <p><code>db.TR{TRID, ProjectID, TemplateID, version}</code><br> <code>db.Project{ProjectID, ProjectName}</code><br> <code>db.Template{TemplateID, TemplateName}</code> </p> <p>I would like the best approach to display all the results in a grid like this: </p> <p><code>TRID - ProjectName - TemplateName - Version</code> </p> <p>I would like to know how you would do the Model, Controller(Index Function) and the view. </p> <p>So far, my View function looks like this: </p> <pre><code>public ViewResult Index() { var viewModel = from tr in db.TRs join proj in db.Projects on tr.ProjectID equals proj.ProjectID join templ in db.Templates on tr.TemplateID equals templ.TemplateID orderby proj.ProjectName select new { TRList = tr.TRID, TemplateList = templ.TemplateName, ProjectList = proj.ProjectName, Version = tr.version } return View(viewModel); //Go in Index.cshtml } </code></pre> <p>And the View is: </p> <pre><code>@model IEnumerable &lt;OnlineTR.WebUI.Areas.Admin.Models.TRManagerModel&gt; @foreach (var item in Model) { &lt;tr&gt; &lt;td&gt; @Html.DisplayFor(modelitem =&gt; item.TRList); &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelitem =&gt; item.ProjectList); &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelitem =&gt; item.TemplateList); &lt;/td&gt; &lt;/tr&gt; } </code></pre> <p>I'm trying to find a way to use a sql request that only use what I need. </p> <p>If you can show me how to use the .include, it would be awesome. So far I have try, but it doesn't accept lambda expressions in the (), it wants a string path. (maybe missing a using?) </p> <p>Thanks a lot. Alex.</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