Back to Devexpress

UseInAuditTrailAttribute Class

expressappframework-devexpress-dot-persistent-dot-base-6f4b5bb6.md

latest3.3 KB
Original Source

UseInAuditTrailAttribute Class

Specifies whether a property takes part in audit.

Namespace : DevExpress.Persistent.Base

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class UseInAuditTrailAttribute :
    Attribute
vb
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple:=False)>
Public Class UseInAuditTrailAttribute
    Inherits Attribute

Remarks

The UseInAuditTrailAttribute is a part of Audit Trail Module functionality and specifies whether a property participates in the audit. You can use this attribute to customize the default Audit Trail module behavior.

Default Audit Trail Module Behavior

The Audit Trail Module logs changes in the following objects and properties:

  • Persistent classes.
  • Public writable simple and reference properties defined in persistent classes.
  • Public collection properties defined in persistent classes.

Read-only properties (those without a setter) and properties decorated with the NonPersistentAttribute are excluded from the audit trail.

Exclude a Property from the Audit Trail

Apply the UseInAuditTrailAttribute with its Include parameter set to false to stop logging property changes:

csharp
[UseInAuditTrail(false)]
public virtual string MyPersistentProperty { get; set; }
csharp
[UseInAuditTrail(false)]
public string MyPersistentProperty { 
    get { return myPersistentProperty; }
    set { SetPropertyValue(nameof(MyPersistentProperty), ref myPersistentProperty, value); }
}

Include a Non-Persistent Property in the Audit Trail

To log changes in a non-persistent property, apply the UseInAuditTrailAttribute with its Include parameter set to true:

csharp
[UseInAuditTrail(true)]
[NotMapped]
public string MyNonPersistentProperty { get; set; }
csharp
[UseInAuditTrail(true)]
[NonPersistent]
public string MyNonPersistentProperty {
    get { return myNonPersistentProperty; }
    set { SetPropertyValue(nameof(MyNonPersistentProperty), ref myNonPersistentProperty, value); }
}

Inheritance

Object Attribute UseInAuditTrailAttribute

See Also

UseInAuditTrailAttribute Members

DevExpress.Persistent.Base Namespace