Hi varun3752,
As per your query you are returning Anonymus Type from the result. So you need return cndDetailsPersonal as a list result and then pass the List as model to the View.
Check this example. Now please take its reference and correct your code.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
Model
public class cndPersonalDetail
{
public string CustomerId { get; set; }
public string ContactName { get; set; }
public int OrderID { get; set; }
public DateTime? Date { get; set; }
public decimal Price { get; set; }
}
Controller
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
NorthwindEntities db1 = new NorthwindEntities();
string id = db1.Customers.Where(x => x.CustomerID == "TOMSP").Select(x => x.CustomerID).FirstOrDefault();
NorthwindEntities1 db2 = new NorthwindEntities1();
List<cndDetailsPersonal> result = new List<cndDetailsPersonal>();
result = db2.Customers
.Join(db2.Orders, c => c.CustomerID, o => o.CustomerID, (a, b) => new { a, b })
.Join(db2.Order_Details, o => o.b.OrderID, od => od.OrderID, (r, reg) => new { r, reg })
.Where(m => m.r.b.CustomerID == id)
.Select(m => new cndDetailsPersonal
{
CustomerId = m.r.a.CustomerID,
ContactName = m.r.a.ContactName,
OrderID = m.r.b.OrderID,
Date = m.r.b.RequiredDate,
Price = m.reg.UnitPrice
}).ToList();
return View(result);
}
}
View
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Join_Multiple_Tables_MVC.Models.cndDetailsPersonal>>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Index</title>
</head>
<body>
<p><%:Html.ActionLink("Create New", "Create")%></p>
<table class="table">
<tr>
<th>Customer Id</th>
<th>Name</th>
<th>Order Id</th>
<th>Date</th>
<th>Price</th>
<th></th>
</tr>
<% foreach (var item in Model)
{ %>
<tr>
<td><%: item.CustomerId %></td>
<td><%: item.ContactName %></td>
<td><%: item.OrderID %></td>
<td><%: String.Format("{0:g}", item.Date) %></td>
<td><%: String.Format("{0:N2}", item.Price) %></td>
<td>
<%: Html.ActionLink("Edit", "Edit", new { id=item.CustomerId }) %> |
<%: Html.ActionLink("Details", "Details", new { id = item.CustomerId })%> |
<%: Html.ActionLink("Delete", "Delete", new { id = item.CustomerId })%>
</td>
</tr>
<% } %>
</table>
</body>
</html>
Screenshot
![](https://i.imgur.com/PLSNzY2.png)