title: C# Filter List to remove any double object
body: <p>Have searched ant tested many examples in this forum but can't get a fully working method.</p>
  
  <p>I am using linq to bulk insert a list of entity classes (RemoteReadings).</p>
  
  <p>Due to unique constraints I need to filter out any items already inserted. </p>
  
  <p>Uniqiuness is composed of 2 columns meterid and datetime in RemoteReadings table.</p>
  
  <pre><code>// approx 5000 records (I need to do this in batches of 2000 due to a 
  // constraint in L2S,but can do this after get this working)
  List&lt;RemoteReading&gt; lst = createListFromCSV(); 
  
  // Option 1:
  // This does not work as am comparing memory list to db list. I need to use contains() method.
  // Actually am trying to accomplish this infollowing examples.
  
  List&lt;RemoteReading&gt; myLst = (from ri in db.RemoteReadings                                                       
                              from l in lst 
                              where l.meterid = ri.meterid 
                              &amp;&amp; l.date = r.date
                              select ri).ToList();
  ////
  
  // Option2:
  // Get the list from DB that are in memory lst 
  List&lt;RemoteReading&gt; myLst = (from ri in db.RemoteReadings                                                       
                              where 
                              // where in this list by comparing meaterid and datemeaured
                              (from l in lst
                              select 
  /// help here !
  ///
                              select ri).ToList&lt;RemoteInterconnectorReading&gt;();
  
  
  // Option3:
  // Get the list from lst that are not in database
  // I am bit confused here !
  
  
  // Tried also to remove from list any duplicates:
  
  List&lt;RemoteReading&gt; result = List&lt;RemoteReading&gt;)myLst.Except(lst).ToList&lt;RemoteReading&gt;();
  
  
  // Ultimately
  db.RemoteReading.InsertAllOnSubmit(result);
  db.submitChanges();
  </code></pre>
  
  <p>Any help please? </p>