title: LINQ to count number of rows in link table
body: <p>I have the following model</p>
  
  <pre><code>public class Account
  {
      public int Id { get; set; }
      public List&lt;Note&gt; Notes { get; set; }
  }
  </code></pre>
  
  <p>I'm trying to query my nhibernate repository to count the number of notes for a specific account.</p>
  
  <p><code>return this.Data.Where(x =&gt; x.Id == accountId).Select(x =&gt; x.Notes).Count();</code></p>
  
  <p>However no matter how many notes there are, it always returns 1.</p>
  
  <p>I am trying to do this in the most efficient way possible without having to get the account object and then count the number of notes.</p>
  
  <p>Can anyone suggest the Linq equivalent of the following SQL.</p>
  
  <p><code>SELECT Count(*) FROM NoteToAccount WHERE AccountId=?</code></p>
  
  <p>Where NoteToAccount is a link table which sits between the Account and Note tables.</p>