diff --git a/docs/en/framework/infrastructure/audit-logging.md b/docs/en/framework/infrastructure/audit-logging.md index 3392f5ac35..2e6dc83940 100644 --- a/docs/en/framework/infrastructure/audit-logging.md +++ b/docs/en/framework/infrastructure/audit-logging.md @@ -230,6 +230,28 @@ public class MyUser : Entity } ```` +#### Ignore Update Audit Properties And Publish Entity Updated Event + +The `[DisableAuditing]` attribute supports additional configuration options when applied to **entity properties**. + +* **UpdateModificationProps** (default: `true`): When set to `false`, changes to this entity property will not update audit properties (like `LastModificationTime`. +* **PublishEntityEvent** (default: `true`): When set to `false`, changes to this entity property will not publish entity change events (`EntityUpdatedEvent`). + + +````csharp +public class MyUser : Entity +{ + public string Name { get; set; } + + [DisableAuditing(UpdateModificationProps = false, PublishEntityEvent = false)] + public string ReadCount { get; set; } +} +```` + +This example will ignore update audit properties and publish entity updated event when the `ReadCount` property is updated. + +> The `UpdateModificationProps` and `PublishEntityEvent` only work for [Entity Framework Core](../data/entity-framework-core). It will not work for [MongoDB](../data/mongodb). + ## IAuditingStore `IAuditingStore` is an interface that is used to save the audit log objects (explained below) by the ABP. If you need to save the audit log objects to a custom data store, you can implement the `IAuditingStore` in your own application and replace using the [dependency injection system](../fundamentals/dependency-injection.md). diff --git a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/DisableAuditingAttribute.cs b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/DisableAuditingAttribute.cs index 3e2328ba75..1e270b643a 100644 --- a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/DisableAuditingAttribute.cs +++ b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/DisableAuditingAttribute.cs @@ -5,7 +5,13 @@ namespace Volo.Abp.Auditing; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property)] public class DisableAuditingAttribute : Attribute { + /// + /// When set to false, changes to this entity property will not update audit properties (like ). + /// public bool UpdateModificationProps { get; set; } = true; + /// + /// When set to false, changes to this entity property will not publish entity change events (). + /// public bool PublishEntityEvent { get; set; } = true; }