Using LINQ is this the best way to clear a table?http://forums.asp.net/t/1773589.aspx/1?Using+LINQ+is+this+the+best+way+to+clear+a+table+Fri, 24 Feb 2012 20:51:08 -050017735894850033http://forums.asp.net/p/1773589/4850033.aspx/1?Using+LINQ+is+this+the+best+way+to+clear+a+table+Using LINQ is this the best way to clear a table? <p><br> <span face="Consolas" size="2" color="#0000ff" style="color:#0000ff; font-family:Consolas; font-size:small"><span face="Consolas" size="2" color="#0000ff" style="color:#0000ff; font-family:Consolas; font-size:small"><span face="Consolas" size="2" color="#0000ff" style="color:#0000ff; font-family:Consolas; font-size:small">foreach</span></span></span><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"> ( </span></span><span face="Consolas" size="2" color="#2b91af" style="color:#2b91af; font-family:Consolas; font-size:small"><span face="Consolas" size="2" color="#2b91af" style="color:#2b91af; font-family:Consolas; font-size:small"><span face="Consolas" size="2" color="#2b91af" style="color:#2b91af; font-family:Consolas; font-size:small">LogErrors</span></span></span><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"> log </span></span><span face="Consolas" size="2" color="#0000ff" style="color:#0000ff; font-family:Consolas; font-size:small"><span face="Consolas" size="2" color="#0000ff" style="color:#0000ff; font-family:Consolas; font-size:small"><span face="Consolas" size="2" color="#0000ff" style="color:#0000ff; font-family:Consolas; font-size:small">in</span></span></span><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"> GetAll() )<br> </span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; db.LogErrors.Remove( log );<br> <br> &nbsp;db.SaveChanges();</p> <p></p> 2012-02-24T20:35:21-05:004850043http://forums.asp.net/p/1773589/4850043.aspx/1?Re+Using+LINQ+is+this+the+best+way+to+clear+a+table+Re: Using LINQ is this the best way to clear a table? <p>If you want to use straight linq, I believe you have to do them one at a time like you have above.</p> <p>Have you tried using inline sql? this is faster&nbsp;</p> <p>&nbsp;db.Database.ExecuteSqlCommand(&quot;Truncate table LogErrors&quot;);</p> 2012-02-24T20:51:08-05:00