title: Using DeleteAllOnSubmit when the table has no primary key
body: <p>I am trying to delete records from a DB which has no primary key. The following works:</p>
  
  <pre><code>using (myDataContext db = new myDataContext ())
  {
      db.ExecuteCommand("DELETE FROM myTable WHERE TradeDate = {0}", date);
  }
  </code></pre>
  
  <p>(where <code>date</code> is an input to the function). But when I try convert it to LINQ</p>
  
  <pre><code>using (myDataContext db = new myDataContext ())
  {
      db.myTable.DeleteAllOnSubmit(db.myTable.Where(t =&gt; t.TradeDate.Date == date.Date));
      db.SubmitChanges();
  }
  </code></pre>
  
  <p>I get the following error because the table doesn't have a primary key:</p>
  
  <blockquote>
    <p>Additional information: Can't perform Create, Update, or Delete operations on 'Table(myTable)' because it has no primary key.</p>
  </blockquote>
  
  <p>I found the following old posts about this issue </p>
  
  <p><a href="http://www.hivmr.com/db/a733739ac119cjf81j9kdxd8afjfa9s9" rel="nofollow">DB:4.44:Dml Operations Using Linq Query For A Table Without Primary Key zm</a></p>
  
  <p><a href="https://social.msdn.microsoft.com/Forums/en-US/48bca7f0-2c86-4c0b-a8b4-258ac344fbfb/dml-operations-using-linq-query-for-a-table-without-primary-key?forum=linqprojectgeneral" rel="nofollow">Dml Operations using linq query for a table without primary key.</a></p>
  
  <p>But I don't understand how to implement the fix they suggest (i.e. setting another key to <code>IsPrimary</code>).</p>
  
  <p>Is there a way to do this using LINQ? Bear in mind that adding a PK to the actual SQL table is not an option (unless I just add a row counting identity column).</p>