title: Performance: .Join vs .Contains - Linq to Entities
body: <p>I am using Linq to entities to query the database to get the list of int for further processing. I have two ways to get the list as below:</p>
  
  <p><strong>First is:</strong></p>
  
  <pre><code>List&lt;int&gt; lstBizIds = new List&lt;int&gt;() { 1, 2, 3, 4, 5 };
  List&lt;int&gt; lstProjectIds = context.Projects.Where(x =&gt; lstBizIds.Contains(x.businessId)).Select(x =&gt; x.projectId).ToList();
  </code></pre>
  
  <p><strong>Second is:</strong></p>
  
  <pre><code>List&lt;int&gt; lstBizIds = new List&lt;int&gt;() { 1, 2, 3, 4, 5 };
  List&lt;int&gt; lstProjectIds = context.Projects.Join(lstBizIds, p =&gt; p.businessId, u =&gt; u, (p, u) =&gt; p.projectId).ToList();
  </code></pre>
  
  <p>Now my question is which one of the methods above is better performance wise? Also does it affect the performance if the first list i.e. lstBizIds grows in size? Suggest me other ways of implementation as well if that are performance reducing.</p>