Skip to main content
All docs
V24.2
.NET Framework 4.6.2+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

AuditTrailOptions.AuditDataItemPersistentType Property

Specifies the business class used to persist auditing information in the database.

Namespace: DevExpress.ExpressApp.AuditTrail

Assembly: DevExpress.Persistent.BaseImpl.Xpo.v24.2.dll

#Declaration

public Type AuditDataItemPersistentType { get; set; }

#Property Value

Type Description
Type

The type of a business class used to persist auditing information in the database.

#Property Paths

You can access this nested property as listed below:

Object Type Path to AuditDataItemPersistentType
AuditTrailService
.OptionsLegacy .AuditDataItemPersistentType
AuditTrailServiceBase
.Options .AuditDataItemPersistentType

#Remarks

To use this property in your code, inherit a custom class from the AuditDataItemPersistent class or implement the IAuditDataItemPersistent<AuditedObjectWeakReferenceType> interface. Refer to the following example for details.

C#
using DevExpress.Xpo;
using DevExpress.Persistent.BaseImpl;

namespace YourSolutionName.Module.BusinessObjects {
    public class AuditDataItemPersistentEx : AuditDataItemPersistent {
        public AuditDataItemPersistentEx(Session session) : base(session) {
        }

        public AuditDataItemPersistentEx(Session session, string userName, DateTime modifiedOn, string description) : base(session, userName, modifiedOn, description) {
        }

        string _myCustomProperty;
        public string MyCustomProperty {
            get {
                return _myCustomProperty;
            }
            set {
                SetPropertyValue(nameof(MyCustomProperty), ref _myCustomProperty, value);
            }
        }

        protected override void OnSaving() {
            base.OnSaving();
            MyCustomProperty = "My custom value";
        }
    }
}

The next step is to set this class to AuditDataItemPersistentType in the Startup.cs file:

C#
public void ConfigureServices(IServiceCollection services) {
    // ...    
    services.AddXaf(Configuration, builder => {
        // ...
        builder.UseApplication<YourSolutionName>();
        builder.Modules
            .AddAuditTrailXpo(opt => {
                opt.AuditDataItemPersistentType = typeof(AuditDataItemPersistentEx);
            })
    }
}
See Also