调用Xpo对象的Delete方法时默认并不物理删除记录,只是给该记录打上标记。若需要物理上删除,需调用 Session.PurgeDeletedObjects 方法。对UnitofWork 来说,已测试调用该方法后不需要再 CommitChanges。 

Deferred Object Deletion

If the XPObject or XPCustomObject is used as the base class for persistent objects, deferred deletion is enabled. This means that when you delete a persistent object by calling its XPBaseObject.Delete method, XPO does not physically delete the record in the underlying data store. Instead, it marks the record as deleted. This technique avoids database exceptions when deleting objects that are referenced by other objects.

By default, objects marked as deleted are never retrieved from the object store unless they are referenced directly. A delete operation also deletes all aggregated objects (see AggregatedAttribute).

You can also use the Session.Delete method to delete persistent objects. Pass a collection of objects which you want to delete as a parameter to this method and it will call the XPBaseObject.Delete method for every object within the collection. The Session.PurgeDeletedObjects method will actually delete objects marked as deleted and all the corresponding records from a data store.

Deleted objects can be restored later on, see How to restore deleted object (records).

 


posted on 2010-02-01 19:41  Elvin Chen  阅读(941)  评论(0编辑  收藏  举报