Lücks
Lücks

Reputation: 3984

Query With Join

I'm working with C# MVC3 and Entity Framework. I have a table that contains 2 FK's. So, I want to execute this query:

SELECT *
  FROM TABLE1 f,
       TABLE2       r,
       TABLE3       c
 WHERE f.codx = r.codx
   AND f.cody = c.cody

TABLE1 = Contains FK's

So, I need to Include at his DbSet a reference the tables.... But, How can I add two tables at my DbSet? The problem that I receive this DbSet from another class, and add in my query:

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>());

How can I do this?

Thanks!

Upvotes: 0

Views: 90

Answers (1)

Mike Christensen
Mike Christensen

Reputation: 91590

You can chain multiple .Include methods together:

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

Upvotes: 1

Related Questions