What Changed
If an application uses EF Core and Middle Tier Security, the IXafEntityObject.OnSaving() method is now called only on the Middle Tier server side when the application is saving an object.
Reasons for Change
When using Middle Tier Security, some security-sensitive properties should only be changed on the server side. You can find an example of such a usage scenario here: How to implement the CreatedBy, CreatedOn and UpdatedBy, UpdatedOn properties in a business class. In order to support this and other similar usage scenarios, the Middle Tier Security Server calls the IXafEntityObject.OnSaving() method before saving the object to the database.
Impact on Existing Apps
The change affects XAF and non-XAF applications that use EF Core and Middle Tier Security mode. If any business logic is implemented in the IXafEntityObject.OnSaving() method, this logic will now be executed on the Middle Tier Security server side.
How to Revert to Previous Behavior
- Enable client-side calling of the IXafEntityObject.OnSaving() method in a Windows Forms application. Add the following option to Application Builder:
File: MySolution.Win\Startup.cs
C#public class ApplicationBuilder : IDesignTimeApplicationFactory {
public static WinApplication BuildApplication(string connectionString) {
// ...
builder.Security
.UseMiddleTierMode(options => {
options.EnableClientSideXafEntityObjectOnSavingCall = true;
// ...
})
// ...
}
}
- In the IXafEntityObject.OnSaving() method in Business Object classes, implement a check for whether the code is executed on the Middle Tier Server side as follows.
C#using DevExpress.ExpressApp.EFCore;
// ...
public class BusinessObject : BaseObject {
// ...
public override void OnSaving() {
base.OnSaving();
if (!SecuredPropertySetter.IsRunningOnMiddleTierServer(this)) {
// ...
}
}
}