Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Delete all listitems

  Asked By: Tanesha    Date: Mar 25    Category: Sharepoint    Views: 1770

i need to delete all listitems in a list. I miss a kind of list.Clear()
method that deletes the items effectively. The reason the items is
deleted is that this list is updated with occurrences from several
lists.

Today i am using

while (list.Items.Count > 0)
list.Items.Delete(0);

It takes a long time deleting this way when there is several thousands
of items to delete.

Any way to improve the performance of deleting items?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Elaina Suarez     Answered On: Mar 25

You can do either a CAML query to get a dataset, or just the getdataset from
list  and then use .DeleteByID.

We've found that's much faster.

 
Answer #2    Answered By: Kacey Russo     Answered On: Mar 25

Deleting 200 occurrences went from 43 seconds to 16 seconds. Thats
improvement!

 
Didn't find what you were looking for? Find more on Delete all listitems Or get search suggestion and latest updates.




Tagged: