Controller:
public ActionResult Index()
{
var Cs = new List<Customer>();
using (JoinEntities db = new JoinEntities())
{
Cs = (from p in db.Customers
join e in db.Orders on p.ID equals e.Customer_id
where p.Name == "Rama"
select p).ToList();
}
return View(Cs);
}
View:
@model IEnumerable<JOIN.Models.Customer>
@{
ViewBag.Title = "Home Page";
}
<table class="table table-condensed table-hover">
<thead>
<tr>
<td>First Name</td>
<td>salary</td>
<td>age</td>
<td>amount</td>
</tr>
</thead>
<tbody>
@foreach (var per in Model)
{
<tr>
<td>@per.ID</td>
<td>@per.Name</td>
<td>@per.Age</td>
<td>@per.Amount</td>
</tr>
}
</tbody>
</table>
This above code view is it taking only one table columns how can I get the other table columns in customer table id is the primary key and order table customer_id is the foreign key
customertable: id, name, age, salary columnsordertable: oid, date, customer_id, amount columns