且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Ado.net实体数据模型中添加条件

更新时间:2023-12-05 21:05:40

要通过id获取任务,您需要在单独的方法中实现它,例如GetTaskById(int taskId).并生成此行以通过EF
访问Tasks表
this._Tasks = base.CreateQuery<tasks>("[Tasks]");

因此,请勿尝试对其进行更改.
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.


public Task GetTaskById(int taskId)
{
   yourDBEntities db=new yourDBEntities ();
   return db.Tasks.Where(task=>task.TaskId=taskId);
 }


否.您需要使用新类创建新文件. F.e. TaskRepository,您将在其中实现DAL. Entity Framework生成的Edmx文件需要在您的数据库和yourDBentities类之间提供映射.
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.