title: Two LINQ statements that should return the same thing are not
body: <p>This is for LINQ to SQL</p>
  
  <p>Here is the first query:</p>
  
  <pre><code>            var rc = from site in customer.OrganizationSites
                   from gt in site.GeneralTransactions
                   where (gt.DealPackage.PackageTransactionDetail.StartDate &lt;= periodStart
                   &amp;&amp; gt.DealPackage.PackageTransactionDetail.EndDate &gt;= periodEnd)
                   || (gt.DealPackage.PackageTransactionDetail.StartDate &gt;= periodStart
                   &amp;&amp; gt.DealPackage.PackageTransactionDetail.EndDate &lt;= periodEnd)
                   &amp;&amp; gt.IsVerified.HasValue
                   &amp;&amp; gt.IsVerified.Value
                   &amp;&amp; (!gt.Invoices.Any()
                   || !gt.Invoices.Any(i =&gt; i.StartDate &gt;= periodStart &amp;&amp; i.EndDate &lt;= periodEnd))
                   select gt;
  </code></pre>
  
  <p>Here is the second:</p>
  
  <pre><code>var rc = from site in customer.OrganizationSites
       from gt in site.GeneralTransactions
       where (gt.DealPackage.PackageTransactionDetail.StartDate &lt;= periodStart
       &amp;&amp; gt.DealPackage.PackageTransactionDetail.EndDate &gt;= periodEnd)
       || (gt.DealPackage.PackageTransactionDetail.StartDate &gt;= periodStart
       &amp;&amp; gt.DealPackage.PackageTransactionDetail.EndDate &lt;= periodEnd)
       &amp;&amp; gt.IsVerified.HasValue
       &amp;&amp; gt.IsVerified.Value
       select gt;
  
  rc = from gt in rc
       where !gt.Invoices.Any()
       || !gt.Invoices.Any(i =&gt; i.StartDate &gt;= periodStart &amp;&amp; i.EndDate &lt;= periodEnd)
       select gt;
  </code></pre>
  
  <p>The second one simply does the first one in two steps but the second one returns what I'm actually looking for (in this case, nothing), I think I'm making an error somewhere but can't see where. I'd greatly appreciate if anyone could point out why.</p>