title: LINQ to Entities / LINQ to SQL: switching from server (queryable) to client (enumerable) in the middle of a query comprehension?
body: <p>In many cases, I want to do some filtering (and sometimes projection) on the server side and then switch to client-side for operations that the LINQ provider doesn't natively support.</p>
  
  <p>The naive approach (which is basically what I do now) is to just break it up into multiple queries, similar to:</p>
  
  <pre><code>var fromServer = from t in context.Table
                   where t.Col1 = 123
                   where t.Col2 = "blah"
                   select t;
  
  var clientSide = from t in fromServer.AsEnumerable()
                   where t.Col3.Split('/').Last() == "whatever"
                   select t.Col4;
  </code></pre>
  
  <p>However, there are many times where this is more code/trouble than it's really worth.  I'd really like to do a 'switch to client side' in the middle. I've tried various methods of using a query continuation, but after doing a 'select t into foo' at the end of the first query, foo is still an individual item, not the collection, so I can't AsEnumerable() it.</p>
  
  <p>My goal is to be able write something more like:</p>
  
  <pre><code>var results = from t in context.Table
                where t.Col1 = 123
                where t.Col2 = "blah"
                // Magic happens here to switch to the client side
                where t.Col3.Split('/').Last() == "whatever"
                select t.Col4;
  </code></pre>