Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 带联接的查询_Sql_Entity Framework - Fatal编程技术网

Sql 带联接的查询

Sql 带联接的查询,sql,entity-framework,Sql,Entity Framework,我正在使用C MVC3和实体框架。 我有一个包含两个FK的表。 所以,我想执行这个查询: SELECT * FROM TABLE1 f, TABLE2 r, TABLE3 c WHERE f.codx = r.codx AND f.cody = c.cody 表1=包含FK的 因此,我需要在他的数据库集中包含一个表的引用。。。。 但是,如何在DbSet中添加两个表呢? 问题是,我从另一个类接收此DbSet,并将其添加到我的查询中:

我正在使用C MVC3和实体框架。 我有一个包含两个FK的表。 所以,我想执行这个查询:

SELECT *
  FROM TABLE1 f,
       TABLE2       r,
       TABLE3       c
 WHERE f.codx = r.codx
   AND f.cody = c.cody
表1=包含FK的

因此,我需要在他的数据库集中包含一个表的引用。。。。 但是,如何在DbSet中添加两个表呢? 问题是,我从另一个类接收此DbSet,并将其添加到我的查询中:

return ((from table1 in this.GetContext<Fake>().TABLE1.Include("TABLE2") //Here I need to Include another table, was working with just one
        where (
      ............. )
        select).ToList<Table1>());
我该怎么做

谢谢

您可以链接多个。将方法包括在一起:

return ((from table1 in this.GetContext<Fake>().TABLE1.Include("TABLE2").Include("TABLE3")
        where (
      ............. )
        select).ToList<Table1>());

但是,我不会将表3包括在表2中?顺序与此无关。所有映射都是通过模型知道的。