title: LINQ query has bad performance while putting .ToArray() inside from/in
body: <pre><code>// the following approach takes sooooooo long
  var result = (
      from t in (
          from a in ctx.t1
          from b in ctx.t2
          where a.id == b.id
          select new { a, b }
      ).ToArray()
      from c in ctx.t3.ToArray()
      where c.name.Contains(t.a.name)
      select new { t.a, t.b, c }
  ).ToArray();
  
  // while the following approach takes time in seconds
  var tSet = (
      from a in ctx.t1
      from b in ctx.t2
      where a.id == b.id
      select new { a, b }
  ).ToArray();
  var cSet = ctx.t3.ToArray();
  var result = (
      from t in tSet
      from c in cSet 
      where c.name.Contains(t.a.name)
      select new { t.a, t.b, c }
  ).ToArray();
  </code></pre>
  <p>Please consider the codes above. FMPOV, these two approaches are the same as dataset (<code>t1</code> &amp; <code>t2</code>) and <code>t3</code> in both approaches will be evaluated before &quot;second&quot; where caluse is applying on to them.</p>
  <p>However, the actual case is that the first approach is taking way so longer than second approach. May I know why?</p>
  <p>Thanks in advance.</p>