title: Sitecore 7 Search, cannot access a disposed object
body: <p>I've been working with some Sitecore 7 search code. Example below. </p>
  
  <pre><code>using (var context = Index.CreateSearchContext())
  {
      // ....Build predicates
  
      var query = context.GetQueryable&lt;SearchResultItem&gt;().Where(predicate); 
      return query.GetResults();
  }
  </code></pre>
  
  <p>This works fine in SOLR, but when used with standard Lucene, whenever I reference a property in the <code>SearchResults&lt;SearchResultItem&gt;</code> returned by <code>GetResults()</code>, Sitecore errors with  "<code>Cannot access a disposed object</code>". It appears that <code>GetResults()</code> doesn't enumerate and still hangs on to the searchcontext. </p>
  
  <p>Anyone come across this before and know how to fix? I've seen some articles suggesting having the <code>SearchContext</code> in application state, but ideally I want to avoid this.</p>
  
  <p>Thanks</p>
  
  <p>Ian</p>