title: linq where count of collection greater than
body: <p>I have a class which have a collection and I want to select those object where count of its collection greater that specific value.</p>
  
  <p>Here is a sample of my class </p>
  
  <pre><code>class Tag{
  
      public int Id { get; set; }
      ....
      public IList&lt;Article&gt; Articles { get; set; }
  
  } 
  </code></pre>
  
  <p>I have try using this linq code</p>
  
  <pre><code>var topTag = _tagRepo.SearchAll(ActiveState.ACTIVE)
                       .Where(t =&gt; t.Articles.Count &gt; 50)
                       .ToList();
  </code></pre>
  
  <p>But the result is invalid, there are still many tag object with article less than 50.
  what's wrong with my code? Did i do it in a wrong way?</p>
  
  <p><em>--- found mistake after see Agent Shark answer but already deleted ---</em></p>
  
  <p>I forgot to add function inside Count(x => ..) so articles of tag doesn't include past article. Now my code have work as it should be..</p>
  
  <p>here is my updated code:</p>
  
  <pre><code>var topTag = _tagRepo.SearchAll(ActiveState.ACTIVE)
                       .Where(t =&gt; t.Articles.Count(a =&gt; a.ReleaseDate &gt;= DateTime.Now.Date ) &gt; 50)
                       .ToList();
  </code></pre>
  
  <p>Thanks a lot guys :D</p>