I\'m running into an issue in the View with pulling data from different entities. Basically I have a bridging entity CategoryProduct that brings together Category and Product da
Why can't you just change the viewmodel something like this
public class MyProduct
{
public int ProductId { get; set; }
public string Title { get; set; }
public virtual ICollection<Category> CategoryList { get; set; }
}
and view
@model IEnumerable<ProductsCode.Models.MyProduct>
<h2>Index</h2>
<table>
<tr>
<th>Product</th>
@Html.DisplayFor(modelItem => item.ProductId)
<th>Categories for Product</th>
</tr>
@foreach (var item in Model.CategoryList) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.CategoryId)
</td>
</tr>
}
</table>