How to limit the number of items being deleted?

Posts   
 
    
Posts: 6
Joined: 12-Jul-2006
# Posted on: 10-Feb-2009 10:44:06   

How can I limit the number of items being deleted (I'm using the adapter scenario) without fetching the records first? So basically, I want to construct a query like "DELETE TOP 100 FROM ....". Is this possible?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 10-Feb-2009 11:12:35   

There is no direct way to implement this, but you can use the RelationPredicateBucket parameter to pass a FieldCompareSetPredicate to filter on the same table using TOP, something that should produce the following:

DELETE FROM Customer
WHERE Id IN (SELECT TOP 100 Id FROM Customer WHERE .....)
Posts: 6
Joined: 12-Jul-2006
# Posted on: 10-Feb-2009 11:59:07   

Thanks, that worked.