Little context:
I have a link model which has a foreign Key ID to the identifier model and client model.
The client model and identifier model have the link model as a virtual Icollection.
- Both the Client model and the identifier model have a foreign Key ID to another model MJTopics.
I'm using EF6 to create controllers with views and on the details view of the Client controller I can pull information from the links icollection into the view however I want to pull in identifiers which share the same MJTopicsID as the Client as shown below:
Use of the Links Icollection in Client Details:
<h3>Links Built</h3>
<table class="table">
<tr>
<th>Domain</th>
<th>Page Containing Link</th>
<th>Anchor Text</th>
<th>Date</th>
<th>Action</th>
</tr>
@foreach (var item in Model.Links)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Identifier.domain)
</td>
<td>
@Html.DisplayFor(modelItem => item.Obdomain)
</td>
<td>
@Html.DisplayFor(modelItem => item.Anchor)
</td>
<td>
@Html.DisplayFor(modelItem => item.BuildDate)
</td>
<td>
@Html.ActionLink("Edit", "Edit", "Status", new { id=item.LinkID }) |
@Html.ActionLink("Domain", "Details", "Status", new { id=item.LinkID }) |
@Html.ActionLink("Delete", "Delete", "Status", new { id=item.LinkID })
</td>
</tr>
}
</table>
Possible related domains (I set a viewbag variable for the MJTopics ID of the client):
<h3>Possible Related Domains</h3>
<table class="table">
<tr>
<th>Domain</th>
<th>Status</th>
<th>Date</th>
<th>Action</th>
</tr>
@foreach (var item in Model.Identifier.Where(p=>p.MJTopics.ID == ViewBag.MjTopicsID))
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Identifier.domain)
</td>
<td>
@Html.DisplayFor(modelItem => item.status)
</td>
<td>
@Html.DisplayFor(modelItem => item.Last)
</td>
<td>
@Html.ActionLink("Go Live", "Live", "Status", new { id=item.StatusID }) |
@Html.ActionLink("Edit", "Edit", "Status", new { id=item.StatusID }) |
@Html.ActionLink("Domain", "Details", "Status", new { id=item.StatusID }) |
@Html.ActionLink("Delete", "Delete", "Status", new { id=item.StatusID })
</td>
</tr>
}
</table>
How would I go about doing this? I tried specifying another model in parenthesis but obviously it only allows one model per view, the only other way I have read about is partial views but don't know anything about these as of yet. Is there another simple way?