Merge Changes when Two Users Edit the Same Record Simultaneously

In multi-user data-aware applications, there are times when one user edits a record while another user is editing the same record. As long as the changes being made do not affect the same field (e.g., one user modifies the task description while another user attaches a file), XAF can resolve the situation, and merge simultaneous changes made by different users. Refer to the Concepts > Business Model Design > Business Model Design with XPO > Optimistic Concurrency Control help topic for more details.

To try out this functionality (which will be available in version 13.1 of XAF), add the following code to your Program.cs file.

static void Main() {
DevExpress.Xpo.XpoDefault.TrackPropertiesModifications = true;
// ...
Note that ASP.NET applications are not supported, because user interaction dialogs are currently only implemented for WinForms. The core helper classes are located in the DevExpress.ExpressApp.Xpo assembly so that support for ASP.NET can be added in the future.

Important note:

To support this functionality, persistent properties should be implemented in a specific manner. If you implement your business model in code, then follow XPO best practices and use either the SetPropertyValue or OnChanged method in persistent property setters. These methods have several overloads. Use the overloads that take both the old and new property values:

SetPropertyValue("PropertyName", ref propertyValueHolder, value);
OnChanged("PropertyName", propertyValueHolder, value)

If you use the Data Model Designer or Business Object Designer to create the data model, then you do not need to worry about implementing persistent properties. Designers automatically declare persistent properties in the proper manner.
If you have any questions about this functionality, feel free to leave a comment below.
13 comment(s)
Adam Latimer

5 stars isn't enough.  Can't wait!

16 May, 2013
Dave Hesketh

I see your 5 stars and raise you another 5...

16 May, 2013

Very interesting.

But what about rules ?  An object that could be valid in the Save context could become invalid when merged.

16 May, 2013
Edilson Junior


16 May, 2013
Duane Coleman

That's absolutely amazing!!   What would happen if two users are editing the same field?   Will it handle modifying collections?  

16 May, 2013
Konstantin B (DevExpress)

> An object that could be valid in the Save context could become invalid when merged.

As you can see in my video, the Save action is still active after I click Merge. It means that the Merge operation doesn't commit my changes. It updates field values that were modified by another user in UI. After that, I will click Save again, and validation rules will trigger (if any).

17 May, 2013
Martin Hart

Konstantin: What's the reason this is implemented in XAF and not XPO?

I have a home-grown solution for this under XPO, but it would be nice to be able to use the 'official' approach.

17 May, 2013
Konstantin B (DevExpress)

> What's the reason this is implemented in XAF and not XPO?

Martin, the Session.TrackPropertiesModifications property is pure XPO feature. You can enable it for a particular Session, or globally via XpoDefault. But XPO is not a UI framework and you will have to implement user interaction yourself. To see how it works in pure XPO, run the XPO Tutorials v12.2 demo and navigate to the Track Properties Modifications section.

17 May, 2013
Konstantin B (DevExpress)

> What would happen if two users are editing the same field?

If both users change the same field value, merging is not possible and a user can either refresh data or cancel saving.

17 May, 2013
Konstantin B (DevExpress)

> Will it handle modifying collections?

Yes, collection properties are supported.

17 May, 2013
Duane Coleman

Thanks for the answers and great work guys!!

17 May, 2013
Roman Shelomanov

WEB platform is main for most of our applications. What we must to do to support this in WEB?

19 May, 2013
Manel Mateu



Just need discover how localize the message and buttons.

24 July, 2013

Please login or register to post comments.