Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I'm using EF 4.0, i have 2 tables "Employee" and "Company" in my database with a relation one_to_many. What I want is to get Employees with only 2 properties (not all) from Company table.
Is there a way to do this in EF 4.0.
I used Include method but i get all properties of company, Can anyone help me?
Posted

1 solution

I'm not sure what EF 4 is, but in .NET, you can easily do this with SQL:
SELECT Employee.Column1, Employee.Column2, Employee.Column3, Company.Column4, Company.Column5 FROM Employee INNER JOIN Company ON Employee.CompanyID=Company.ID

Column1, Column2, Column3, Column4 & Column5 are columns that you want to show, and CompanyID from Employee, and ID from Company are related columns. I hope it helped!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900