Mass Delete

Posts   
 
    
Mr Rogers
User
Posts: 7
Joined: 07-Mar-2007
# Posted on: 27-Mar-2007 19:02:03   

I would like to clear all the records from my table Bogus. Is there a way to delete those records without downloading them first in an entity collection? While I'm asking, is there also a way to filter deletes (i.e. all BogusTable rows with IsBogus = 1)? I don't really want to download everything first just to delete them because I could have lots of records. Do I need to do a stored proceedure?

Thanks

fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 27-Mar-2007 19:49:17   

Check out the help section "Generated code - Using the entity collection classes, Adapter" towards the bottom is this:

Deleting one or more entities from the persistent storage If you wish to delete one or more entities from the persistent storage, the same problem as with updating a set of entities appears: you first have to load them into memory, call Delete() and they'll be deleted. To delete a set of entities from the persistent storage directly, you can use the DeleteEntityCollection() method of the DataAccessAdapter object to achieve your goal. This method works with the objects inside the collection and deletes them one by one from the persistent storage using an own transaction if the current collection isn't part of an existing transaction. (See for more information about transactions the section Transactions).

Mr Rogers
User
Posts: 7
Joined: 07-Mar-2007
# Posted on: 27-Mar-2007 19:59:35   

Is there no way to delete a set of rows without fetching them first?

mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 27-Mar-2007 20:24:22   

Mr wrote:

Is there no way to delete a set of rows without fetching them first?

DataAccessAdapter has a DeleteEntitiesDirectly function. Have a look at that.

Mr Rogers
User
Posts: 7
Joined: 07-Mar-2007
# Posted on: 27-Mar-2007 21:06:21   

Ah, looks great, thanks. I can't believe I missed that.confused