Marius Vasile

Marius Vasile

  • 590
  • 1.9k
  • 149.1k

How do I write a query to include three connected tables

Sep 3 2021 1:28 PM

I have three tables, PTWMain, PTWSubsequent and PTWContent. The relation between them is PTWMain can have multiple PTWSubsequent but only one PTWContent and PTWSubsequent can have only one PTWContent. I try to write a query to get related data from all tables but I failed. What I tried is

PTWContents = await _context.PTWContents.Include(s => s.PTWMain).Include(s => s.PTWSubsequent).ToListAsync();

but this query simple ignore the PTWSubsequent. How it should be written?


Answers (2)