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

I am using Ado.net Entiry data model in my asp.net application.

After I drag my Task table from database, it will create query:
this._Tasks = base.CreateQuery<tasks>("[Tasks]");

I want to add condition here to select task by taskID.

Please help/suggest me on this.

-
YRishi
Posted
Updated 6-Feb-11 22:03pm
v3
Comments
shakil0304003 4-Feb-11 6:19am    
Not Clear!!!
Dalek Dave 7-Feb-11 4:03am    
Edited for Readability.

To get task by id you need to implement it in separate method, f.e. GetTaskById(int taskId). And this line is generated to access to Tasks table by EF

this._Tasks = base.CreateQuery<tasks>("[Tasks]");

So, don't try to change it.
 
Share this answer
 
public Task GetTaskById(int taskId)
{
   yourDBEntities db=new yourDBEntities ();
   return db.Tasks.Where(task=>task.TaskId=taskId);
 }
 
Share this answer
 
Comments
yrishi 7-Feb-11 2:43am    
Thanks for your reply. I have write this code in .edmx file right ?
Dalek Dave 7-Feb-11 4:04am    
Good Call.
No. You need to create new file with new class. F.e. TaskRepository where you'll implement your DAL. Edmx file generated by Entity Framework needs to provide mapping between your DB and yourDBentities class.
 
Share this answer
 
v2
Thanks for your reply.
The method which you are telling me is need to write in .svc file..
like
XML
[WebGet]
        public ObjectResult<Tasks> GetTaskById(int TaskID)
        {
            TasksDBEntities entities = new TasksDBEntities();
            return entities.GetTaskById(TaskID);
        }


isn't it ? please reply so that i can proceed.
 
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