title: Does converting an IEnumerable to IQueryable enumerate the query
body: <p>I am using JQuery widgets's datatable to have a table control in an MVC application with server-side paging, sorting and filtering. When doing the filtering, I have the following method:</p>
  
  <pre><code>private IQueryable&lt;ImportRfqViewModel&gt; BuildLinqQuery(System.Collections.Specialized.NameValueCollection query)
  {
      var result = query.GetValues("filterslength");
      var filtersCount = int.Parse(query.GetValues("filterslength")[0]);
      if (result == null || filtersCount == 0)
      {
          return AllImportRfq();
      }
  
      Predicate&lt;ImportRfqViewModel&gt; orResultPredicate = PredicateExtensions.False&lt;ImportRfqViewModel&gt;();
      for (var i = 0; i &lt; filtersCount; i += 1)
      {
          var filterValue = query.GetValues("filtervalue" + i)[0].ToUpper();
          var filterCondition = query.GetValues("filtercondition" + i)[0];
          var filterDataField = query.GetValues("filterdatafield" + i)[0];
          var filterOperator = query.GetValues("filteroperator" + i)[0];
  
          if (filterDataField == "ImportRfqId")
          {
              Predicate&lt;ImportRfqViewModel&gt; predicate = p =&gt; p.ImportRfqId.ToString().Contains(filterValue);
              orResultPredicate = orResultPredicate.Or(predicate);
          }
          else if (filterDataField == "DateCreated")
          {
              Predicate&lt;ImportRfqViewModel&gt; predicate = p =&gt; p.DateCreated.ToString("yyyy/MM/dd hh:mm:ss").Contains(filterValue);
              orResultPredicate = orResultPredicate.Or(predicate);
          }
          ...
      }
  
      Func&lt;ImportRfqViewModel, bool&gt; funcOr = l =&gt; orResultPredicate(l);
  
      var allResearch = AllImportRfq().Where(funcOr).AsQueryable();
      return allResearch;
  }
  </code></pre>
  
  <p>I'm using the predicates in order to chain Or conditions. I obviously want to return an IQueryable so that the query is not run before I get to the part:</p>
  
  <pre><code>dbResult = dbResult.Skip(pagesize * pagenum).Take(pagesize);
  </code></pre>
  
  <p>The result of the predicate though, is an <code>IEnumerable</code>. This is why I call the <code>.AsQueryable();</code></p>
  
  <p>What I'm concerned about and don't know is whether the thing potentially is enumerating the query and then returning a <code>IQueryable</code> afterwards and throwing away the enumeration, if I'm making sense.</p>
  
  <p>In all this I'm assuming that if I return an <code>IEnumerable</code>, it would execute the query.</p>