Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is there any more efficient way of deleting al list items than getting all items and then deleting them one by one (item.DeleteObject())?

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

How about using the ProcessBatchData method? See this link for example.

share|improve this answer
    
The question was about the Client Object Model. That proposed solution is for the Server Object Model –  user7654 Apr 2 '12 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 Apr 3 '12 at 14:35
add comment

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.

share|improve this answer
    
The 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 Sep 4 '12 at 8:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.