Ticket T499070
Visible to All Users

How to get deleted objects using IObjectSpace's FindObject method?

created 8 years ago

Hello,

I see that the XPO Session object has a FindObject method that will include deleted objects but it does not appear that IObjectSpace does. Am I missing something? How do I retrieve delete objects using an IObjectSpace?

Brian

Answers approved by DevExpress Support

created 8 years ago (modified 5 years ago)

Hello Brian.

IObjectSpace doesn't provide methods to retrieve deleted objects. To access deleted persistent objects, cast the object space instance to XPObjectSpace, access the Session, and use XPO methods (e.g. Session.FindObject<ClassType>(CriteriaOperator, Boolean)) directly. Note that the Deferred Deletion feature was designed to avoid database constraint issues in certain scenarios and not to temporarily hide objects.

If you need to hide some objects while still having them in the database, I recommend that you introduce an additional property to mark such objects and add appropriate filters to XAF list views. Then, you will be able to remove or change the filter when required.

    Comments (2)
    BW BW
    Brian Wheatley 8 years ago

      Michael,

      I'm preparing to roll out a new version of an existing product and the database has changed somewhat (particularly due to the new security system). There will be an option to "migrate" a database for those users who choose to upgrade. The migration tool will import all data including deleted objects so that historical reports will still show the same results. For example, they may need to see how much money they made in 2010 even if there are customers they've deleted because they no longer do business with them. Therefore when I bring a deleted customer over I want to make sure that it is marked as deleted in the new database but still need a way to attach transaction history to the deleted customer.

      DevExpress Support Team 8 years ago

        Thanks for the clarification. The Deferred Deletion feature is not the right solution for this scenario, because deleted objects are intentionally disconnected from others and not visible to regular collections. Based on your description, it is better to mark "deleted" customers using a separate explicit flag property and take its value into account depending on whether or not should they be included in the list.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.