title: IQueryable<T> to List<T> performance issue
body: <p>I have the following code that works fine, but I'm having some issue in terms of its performance. Through debugging, I can see that when the code comes to this line below, it takes 10 seconds to step through. </p>
  
  <pre><code>List&lt;T&gt; queryableListdResult = queryableInitialResult.ToList();
  </code></pre>
  
  <p>Basically this code below grabs about 15000 articles from 150000 records in the database. </p>
  
  <p>Can someone please suggest a better way of doing this? Thanks!</p>
  
  <p>My code: </p>
  
  <pre><code>        public static IQueryable&lt;T&gt; CategoryFilter&lt;T&gt;(IQueryable&lt;T&gt; queryable, int categoryFilterCount, RenderingContext rc, bool CategoryOR, string categoriesforQuery) where T : AbstractResult
          {
  
  
          if (!string.IsNullOrEmpty(categoriesforQuery))
          {
              string[] categoriesDefined = categoriesforQuery.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
              List&lt;T&gt; listInitialResult = new List&lt;T&gt;();
  
  
              foreach (string TaxonomyID in categoriesDefined) //e.g. entertainment, business
              {
                  string categoryToCompare = TaxonomyID.ToString().Replace("{", "").Replace("}", "");
                  queryable = queryable.Where(i =&gt; i.alltags.Contains(categoryToCompare));
  
                  List&lt;T&gt; queryableListdResult = queryable.ToList();
  
  
                  listInitialResult.AddRange(queryableListdResult);
              }
              if (CategoryOR)
              {
                  return listInitialResult.AsQueryable();
              }
              else
              {
                  List&lt;T&gt; queryableFinalResult = (listInitialResult.GroupBy(x =&gt; x._Group).Where(g =&gt; g.Count() &gt;= categoryFilterCount)
                  .Select(g =&gt; g.FirstOrDefault())).ToList();
                  return queryableFinalResult.AsQueryable();
              }
  
          }
          else
          {
              return queryable;
          }
      }
  </code></pre>