Hi,
Kindly tell me some one how can i view record from 3 tables, third maintain fk from first two tables. i am using Entity framework with linq.
Regards
Sudhir
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 3, 2013, 10:06 PM EST
hi,
if you have 3 table says, Empmaster , People and Address and relation is asblow
EMpMaster EmpID is foreing key with people table
People PeopleID is foreing key with address table
EmpMaster --> People --> Address.
now from entity side you must include path upto address relation.
example
ModelContext cx =new ModelContext();
var emp = cx.EmpMaster.Include("People.Address").Where(r=>r.EmpId == 1000);
now it return from controller to View
In view you can use following syntax to view Data of Addresses like.
<%: Html.TextBoxFor(m => m.People.Address.Line1) %>
here i am assuming that there is one to one relation between EmpMaster --> People --> Address.
hope this will help you.
Sudhir Sharma62 reputationPosted Feb 3, 2013, 11:11 PM EST
Thanks for quick response.
I have 3 tables like :
1: Employee (Empid PK, EmployeeName varchar(44))
2: Product (ProdId pk int, ProductName varchar(44))
3 : Employee_Product (EP_id int, Employee FK (from Employee) ,Product FK (form Product) )
Plz tell me how can i view data in View from controller.
if is it possible to share ur cell no. Plz share with me .
Thanks
Sudhir
Cell : 9555289718
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 4, 2013, 1:46 AM EST
hi,
as per your table structure, there is many - many relation between Employee and Product.
so you may find many employee with in one product and vise versa
please share what you want show on the screen?
please share you screen design so that I can help you.
Sudhir Sharma62 reputationPosted Feb 8, 2013, 1:00 AM EST
First one table is Employee Master ,second one for Project Master and last one is for Employee Project , which reference from Project master and also from Employee Master.
My question is " How can i populate data from Employee Project Master in MVC 4 Razor"