Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All,

I have create model.edmx file in which I have used two tables 1)Project and 2)Task
My task are project specific. Henceforth I want to show only those task which project is selected by User.

MY tables are
Project
ProjectID
ProjectName
Description

Task
TaskID
ProjectID
TaskName
Description


When i select tables from database for Model.edmx, it will fetch all the database data so I will be not able to view selected project data.

Please revert me back in case of any other query.
Please share your ideas.

-
YRishi
Posted
Comments
dasblinkenlight 25-Jan-11 5:43am    
I think this question has a better chance of being answered if you ask it in the DB forum, because it's mostly about fetching data using Entity Framework, and not about displaying it using ASP.NET.

Quick & dirty solution

IEnumerable<Task> tasksByProject = context.Projects.Where(project => project.ProjectId == 1).First().Tasks.Where(tasks => tasks.ProjectID == 1);

I am very new in LINQ & Entity Framework thing so this solution may not be the best possible one but this might give you an idea.
 
Share this answer
 
Comments
saini arun 25-Jan-11 6:36am    
Or use "views" in case you want it to be done at database level.
Thanks a lot Saini Arun, This will help me.
 
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