Skip to main content
All docs
V24.1
.NET 6.0+

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.1.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.

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:

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