DeleteAllOnSubmit sends individual Delete Statement

In the application that I am currently working, the user interface allow the end user to select multiple items and mark them for deletion. After marking them for deletion they have to click the submit button to send the changes to the database. Well, I had the those objects in memory so I simply passed those objects to DeleteAllOnSubmit method exposed on datacontext and called submitchanges. I thought that linq to SQL would issue a single statement to the database to delete all those objects but it issued seprate SQL statement to delete each object. Here is an example that illustrates the behavior.

image

image

In the above screen shot, you would notice that there were five delete statement issued by the datacontext. Not sure why linq to SQL statement did not issue a single statement to accomplish the same task.

2 Comments

  • This post might help..

    http://www.aneyfamily.com/terryandann/post/2008/04/Batch-Updates-and-Deletes-with-LINQ-to-SQL.aspx

    Raj

  • Surely individual deletes is exactly what's wanted - if you have in memory a set of rows that you want to delete, you don't generally want to delete using a WHERE filter because this may delete additional rows (such as rows inserted by another user while you weren't looking).

Comments have been disabled for this content.