How to select additional column from joined table and send them all to View as PagedList?
public ViewResult Index(...)
{
var newlist = from n in db.students
join o in db.info on n.id equals o.id
select n;
// ^ This only select collection from "students" as "n".
return View(newlist.ToPagedList(..., ...));
// ^ using PagedList Extenstion
}
I want to join to some others tables and get some additional columns.
Any chance to use it in cshtml file (View) like this?:
@foreach (var item in Model) {
<td>@item.column_from_students_table_1</td>
<td>@item.column_from_students_table_2</td>
<td>@item.column_from_info_table_1</td>
<td>...</td>
}
You could create your own custom view type and select to that:
ViewModel:
Linq Query: