Ticket T144104
Visible to All Users

get "changed" state of xpobject and it´s fields

created 11 years ago

Hi support,

when saving xpcollections and xpobjects to the database i need to know the xpobject in the xpcollection, that is really changed.
And in this changed xpobject i need to know the fields, that changed.
Best would be knowledge of old and new value.

With this information i want to create a special "history" of changed data. This history is limited to a view interesting fields.

I know , there is a changed event but that fires always when changing the field. That would be to often for me. I need it only when saving.

Is there a functionality in xpo or do i have to build this myself via using the changed event and managing a list of changes?

I think, xpobjects do have all the needed infos. I just do not see them while saving data.

Answers approved by DevExpress Support

created 11 years ago (modified 10 years ago)

Hello Hans,

XPO provides capabilities to implement this. You can use the XPMemberInfo.GetModified method to check whether a property is modified, and the XPMemberInfo.GetOldValue method to get the old value. Note that these methods will work only if you enable property modifications tracking using the XpoDefault.TrackPropertiesModifications and Session.TrackPropertiesModifications properties. Refer to the GetPropertiesListForUpdateInsert - How to select modified fields? ticket for additional information.

I have attached a sample project demonstrating how to use these methods to accomplish your task. Another example of how to use these methods is shown here: OptimisticLocking - Enhance Properties Modifications Tracking.

    Show previous comments (1)
    Anatol (DevExpress) 10 years ago

      I have added a sample project to my initial answer. Hope you will find it helpful.

        Hello Anatol,
        thank you for the sample.
        That was  exactly what i needed!
        H.

        Anatol (DevExpress) 10 years ago

          You are welcome!

          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.