title: LINQ - using a selected collection between methods/classes
body: <p>After a lot of searching I wasn't able to find anything that clearly describes why I'm seeing this behavior (and I presume it's something very simple I'm missing - I'm still very much a beginner :)</p>
  
  <p>I have a method (RefreshFilter) that takes an object (rfp) as a parameter.  rfp has a property named 'Items' that is of type List.</p>
  
  <p>I have 2 calls to RefreshFilter that look like this:</p>
  
  <pre><code>rfp = RefreshFilter(rfp, FilteredBy.Category)
  rfp = RefreshFilter(rfp, FilteredBy.Industry)
  </code></pre>
  
  <p>Here is the RefreshFilter method:</p>
  
  <pre><code>public FilterParams RefreshFilterList(FilterParams rfp, FilteredBy filteredBy)
  {
      using (myEntity context as new myEntity())
      {
          itemsInCategory = (from i in context.items
                             join ic in context.ItemsCategories on i.Id equals ic.items.id
                             where ic.Categories.Id == '52'
                             select i).ToList&lt;items&gt;();
  
          rfp.Items = rfp.Items.Intersect(itemsInCategory).ToList&lt;items&gt;();
      }
      return rfp;
  }
  </code></pre>
  
  <p>The first call to RefreshFilter(...) works just fine and returns a FilterParams object with a .items property that contains an intersected list.</p>
  
  <p>The second call to RefreshFilter(...) <strong>always</strong> returns a FilterParams object with a .items property containing an list of <strong>0 elements</strong> (which is not expected since I know there are matching elements in the lists).</p>
  
  <p>Through some testing, I believe I have been able to narrow this down to being related to the context that rfp.Items is set in.  However I was always under the impression that the proper way to share collections between contexts was to select them into collection objects and pass these objects around, but it seems that these objects are still tied to their initial context in some way.</p>
  
  <p>Thanks,</p>