title: How to return records not found in both lists using c# and linq
body: <p>I'm new to linq, and I'm really struggling to get a result from two lists where the records doesn't exist in the second table.</p>
  
  <p>I two classes...</p>
  
  <ul>
  <li><p>cfiles</p>
  
  <ul>
  <li>Year</li>
  <li>session</li>
  <li>centre</li>
  <li>fileNameRaw</li>
  </ul></li>
  <li><p>cfileRecs
  -Id</p>
  
  <ul>
  <li>fileName</li>
  </ul></li>
  </ul>
  
  <p>cfiles, contains all pdf files in the repository, which cfilesRecs contains a database entry for each pdf file.</p>
  
  <p>Both classes are presented as List and List, and I would like to return a list containing only the files not found in cfilesRecs using linq.</p>
  
  <p>Here is the code used, although as you probably see the linq syntax is wrong.</p>
  
  <pre><code>public static void Main(string[] args)
      {
          List&lt;cfileRecs&gt; dbScanRecords = dbRecords();    // Contains db records for objects
          List&lt;cfiles&gt; awsScanObjects;                   // Contains objects from aws
          using (client = new AmazonS3Client(Amazon.RegionEndpoint.EUWest1))
          {
              Console.WriteLine("Listing objects stored in a bucket");
              awsScanObjects = ListingObjects();
          }
  
          List&lt;cfiles&gt; abc = from d in dbScanRecords join aws in awsScanObjects on d.fileName == aws.fileNameRaw
  
      }
  </code></pre>
  
  <p>Example answers deal mainly with comparing to lists of the same type - rather than joining two different lists on a common property value.</p>
  
  <p>Thanks everyone for the examples, but they don't seem to produce the correct result I've created a dotnetfiddle <a href="https://dotnetfiddle.net/MW6gXF" rel="nofollow">https://dotnetfiddle.net/MW6gXF</a> illustrating the problem. The result returns 6 items, where I should be getting only 3.</p>