My requirement as follows, In my database, have tables as follows.In there table called Tbl_loan_details
LOANID
reference to other tables as FK(las_fac_id
and lac_fac_id
).
I need to get all the 3 tables columns to my view called details.
This is my model classes,
public partial class Tbl_Loan_Details
{
public int LOANID { get; set; }
public string LastName { get; set; }
public string FirstName { get; set; }
public string CUSAGE { get; set; }
public string CUSNAME { get; set; }
public string AMOUNT { get; set; }
public string Address { get; set; }
public string City { get; set; }
}
public partial class Tbl_CRIB_Details
{
public int CRIBID { get; set; }
public Nullable<int> LAS_FAC_ID { get; set; }
public string CRIB_NAME { get; set; }
public string CUSAGE { get; set; }
public string CUSNAME { get; set; }
public string CHECQ { get; set; }
public virtual Tbl_Loan_Details Tbl_Loan_Details { get; set; }
}
public partial class Tbl_loan_para
{
public int ID { get; set; }
public string paraName { get; set; }
public string Amount { get; set; }
public Nullable<int> lac_fac_id { get; set; }
public virtual Tbl_Loan_Details Tbl_Loan_Details { get; set; }
}
my controller as follows, currently which accept parameter as id, and return only tbl_loan_details
// GET: /Loan/Details/5
public ActionResult Details(int? id)
{
Tbl_Loan_Details tbl_loan_details = db.Tbl_Loan_Details.Find(id);
return View(tbl_loan_details);
}
view Detail code as follows.
<h2>Details</h2>
<div>
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.LastName)
</dt>
<dd>
@Html.DisplayFor(model => model.LastName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.FirstName)
</dt>
<dd>
@Html.DisplayFor(model => model.FirstName)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.LOANID }) |
</p>
How can I access other table's column in detail view. I mean I need to show following tbl_loan_para(paraName) Tbl_crib_detail(Crbi_name,Checq)
data in details view.
I pass id
to my controller as above code, based on that id I need to show each table data in details view.