title: How to join 3 tables with linq
body: <p>I am trying to join 3 tables in a query with Linq to get data from all 3 tables. Below is an image of the table schemes:</p>
  
  <p><a href="https://i.stack.imgur.com/LXSCX.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/LXSCX.jpg" alt="enter image description here"></a></p>
  
  <p>The query should select: SewagePlantName, CompanyName and Duty</p>
  
  <p>In addition I need to restricts the SewagePlantId to a list of Ids that are given as:</p>
  
  <pre><code>            var sewagePlantIds = UnitOfWork.GetAll&lt;UserGroup&gt;()
              .Where(group =&gt; group.Id == webAppPrincipal.GroupId)
              .SelectMany(group =&gt; group.SewagePlantId).Select(sewageplant =&gt; sewageplant.Id).ToList();
  </code></pre>
  
  <p>I have difficulties with the order of joining the 3 tables and where/how to restrict the SewagePlantId to the given list.</p>