title: Filter two lists on one property c# using linq
body: <p>I have two objects namely <strong>Card</strong> and <strong>Transaction</strong>: </p>
  
  <pre><code>Card:
  public string CardID {get; set;}
  public string TransactionRef {get; set;}
  
  Transaction:
  public string TxnID {get; set;}
  public string TxnDetails {get; set;}
  </code></pre>
  
  <p><strong>Note:</strong> The <code>TransactionRef</code> is of the format <code>Date|TxnID</code></p>
  
  <p>I also have a list of the two objects <code>List&lt;Card&gt; cardDetails</code> and <code>List&lt;Transaction&gt; transDetails</code></p>
  
  <pre><code>cardDetails:
  {CardID = '1', TransactionRef = '20150824|Guid1'}
  {CardID = '2', TransactionRef = '20150824|Guid2'}
  {CardID = '3', TransactionRef = '20150824|Guid3'}
  
  transDetails:
  {TxnID = '23', TxnDetails = 'Guid1'}
  {TxnID = '24', TxnDetails = 'Guid2'}
  </code></pre>
  
  <p>I want to filter cardDetails using transDetails based on TxnDetails so that it filters out the items which do not contain the TxnDetails from the 2nd list.</p>
  
  <p>This should be the output:</p>
  
  <pre><code>cardDetails:
   {CardID = '3', TransactionRef = '20150824|Guid3'}
  </code></pre>
  
  <p>I have tried like this using linq: </p>
  
  <pre><code>  cardDetails = cardDetails.Where(x =&gt; transDetails.Any(y =&gt; x.TransactionRef.Contains(y.TxnDetails) == false)).ToList();
  </code></pre>
  
  <p>but it always returns the list as blank. I have tried many variants of this query without success. I know this question has been asked before and after searching for them and trying out their solutions I am still unable to get it right. </p>
  
  <p>Can anyone suggest what is wrong with my query?</p>
  
  <p><strong>Note:</strong> One thing I forgot to mention is that these lists can contains 1000s of records. So performance is also important.</p>