Deletes persistent objects and their aggregated objects from the data store.
A collection of persistent objects to delete from the data store.
If a persistent object has the DeferredDeletionAttribute, the Delete method does not physically delete the underlying database record. It uses a hidden GCRecord field to mark the object as deleted. Clear all references to the object to delete this object when the Session.PurgeDeletedObjects method is called.
If the DeferredDeletionAttribute is not set, the Delete method removes the underlying database record if this operation does not violate foreign key constraints.
The following code deletes all objects in a collection and deletes the corresponding database records:
using DevExpress.Xpo; using DevExpress.Data.Filtering; // ... var colDelete = new XPCollection<YourPersistentType>(theSession, new BinaryOperator("YourPropertyName", true)); // Objects for deletion. theSession.Delete(colDelete);
When an object with Deferred Deletion enabled is deleted, it is removed from associated collections. Associations cannot be recreated automatically when you restore a deleted object. This behavior is by design, because the Deferred Deletion feature is not intended for object restoration, but for overcoming complex foreign index constraints at the database level.