title: Is Converting between a subtype interface and its base type interface and back again, a bad thing to do?
body: <p>I have an example where I want a IQueryable to convert to an IEnumerable (in order to use a multi-statement lambda), and then I immediately want to convert back to a IQueryable to use an extension method that requires IQueryable.  </p>
  
  <p>This is within a LINQ query if that matters?</p>
  
  <p>My question is whether this can be time or space intensive? Or, more plainly, should I avoid it for any reason?</p>
  
  <p>Here is the use case of this scenario:</p>
  
  <pre><code>var messageTimelines = ctx.UserMessageTimelines.AsEnumerable()
      .Where(w =&gt;
      {
          var intersectCount = w.MessageTimelineParticipants.Intersect(timelineParticipants).Count();
          return ((intersectCount == w.MessageTimelineParticipants.Count()) &amp;&amp; (intersectCount == timelineParticipants.Count()))
              ? true : false;
      }).AsQueryable().ProjectTo&lt;MessageTimeline&gt;(mapper.ConfigurationProvider);
  </code></pre>
  
  <p>As you can see I started off as a IQueryable and converted to 'AsEnumerable()' in order to utilize a multi-statement lambda.  I then converted back to 'AsQueryable()' in order to use an AutoMapper extension method called 'ProjectTo', which requires 'IQueryable'.</p>
  
  <p>To Note:</p>
  
  <ul>
  <li>This post almost answers my question, but doesn't speak of converting back to the sub-type IQueryable:  <a href="https://stackoverflow.com/questions/4061951/does-converting-iqueryable-to-ienumerable-execute-the-query-again">does converting IQueryable to IEnumerable execute the query again?</a></li>
  </ul>