Is there any more efficient way of deleting al list items than getting all items and then deleting them one by one (item.DeleteObject())?
2 Answers
How about using the ProcessBatchData method? See this link for example.
-
2The question was about the Client Object Model. That proposed solution is for the Server Object Modeluser7654– user76542012-04-02 01:47:31 +00:00Commented Apr 2, 2012 at 1:47
-
I've had a similar problem with a large list, 9000 items, each with unique item permissions. I found that there was negligible time differences between switching to the list data view and deleting via select all, iterating over the entire list using PowerShell and finally using PowerShell to run a batch delete command on the list. Each approach took more or less the same amount of time. Should I have expected the Batch delete instruction to be much faster in comparisson or is it really just a nice way to wrap up a large instruction?Brian Scott– Brian Scott2012-04-03 14:35:53 +00:00Commented Apr 3, 2012 at 14:35
Jimbo is correct, ProcessBatchData is for the server API. However, the Client Object Model is more or less batch by default.
You must use DeleteObject( ) on each item, but as in all calls with the COM your commands are batched up and sent to the server only with ExecuteQuery( )
See here
You could use something like Fiddler to see the actual command, I'm not sure if the COM is smart enough to actually send a batch CAML delete or it's just a bundled bunch of single-object deletions.
-
1The commands are batched up, but be aware that the number of commands is limited ! See this page : msdn.microsoft.com/en-us/library/office/…Stef Heyenrath– Stef Heyenrath2012-09-04 08:32:28 +00:00Commented Sep 4, 2012 at 8:32