What Changed
All read-only properties (those without a set accessor) and properties decorated with the [NonPersistentAttribute]
are automatically excluded from the audit trail in v24.1+.
Reasons for Change
Previously, values of all object properties, including non-persistent properties, were copied to the audit log (if you used the Audit Trail module with the FullObjectAuditProcessor
). This behavior could be suboptimal due to the following reasons:
- Since a property is not persistent itself and is typically not intended to be explicitly changed by a user, auditing its changes is unnecessary in most instances.
- In certain instances, getters of non-persistent properties may involve "heavy" logic, such as accessing the database or loading large collections. Auditing such properties can result in a significant amount of unnecessary computation. The performance impact can be especially noticeable when you use the Scheduler Module with auditing enabled.
Impact on Existing Apps
From v24.1 onwards, non-persistent properties are excluded by default from the audit log.
How to Update Existing Apps
Set the DefaultSettingsCompatibilityMode static property to Latest
, 24_1
or a later version.
Alternatively, set the static ObjectAuditProcessor.ExcludeNonPersistentFromAudit
property to true
:
Files:
Blazor - MySolution.Blazor.Server\Program.cs
WinForms - MySolution.Win\Program.cs
Web API - MySolution.WebApi\Program.cs
ASP.NET Web Forms - MySolution\MySolution.Web\Global.asax.cs
C#public static int Main(string[] arguments) {
DevExpress.Persistent.AuditTrail.ObjectAuditProcessor.ExcludeNonPersistentFromAudit=true;
}
How to Revert to Previous Behavior
Use one of the following techniques to revert to the previous behavior:
-
Disable the new behavior globally.
Files:
Blazor - MySolution.Blazor.Server\Program.cs
WinForms - MySolution.Win\Program.cs
Web API - MySolution.WebApi\Program.cs
ASP.NET Web Forms - MySolution\MySolution.Web\Global.asax.csC#public static int Main(string[] arguments) { DevExpress.Persistent.AuditTrail.ObjectAuditProcessor.ExcludeNonPersistentFromAudit=false; }
-
Use
[UseInAuditTrail(true)]
to enable audit for a specific property. (theUseInAuditTrailAttribute
takes precedence over the staticExcludeNonPersistentFromAudit
property).C#[UseInAuditTrail(true)] [NonPersistent] public virtual string NonPersistentUseInAuditTrailTrue { get; set; }