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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sudhir SharmaPosted Feb 8, 2013, 6:00 AM
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"
Jignesh TrivediPosted Feb 4, 2013, 6:46 AM
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 SharmaPosted Feb 4, 2013, 4:11 AM
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 TrivediPosted Feb 4, 2013, 3:06 AM
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.