0

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!

1 Answer 1

1

You can chain multiple .Include methods together:

return ((from table1 in this.GetContext<Fake>().TABLE1.Include("TABLE2").Include("TABLE3")
        where (
      ............. )
        select).ToList<Table1>());
Sign up to request clarification or add additional context in comments.

2 Comments

But, I'll not Include Table3 ON table2?
The order is not relevant. All the mappings are known through the model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.