- Bulk Operations
- FromQuery Operations
- C# Eval Expression
- Options
.NET Bulk Operations Audit
Description
The Bulk Operations audit feature allows you to track changes of all modifications that happened in the database during the Bulk Operations. Also, it lets you create a history of who modified a table, what was an old value and a new value.
Key Features
- Allow getting a history of modification
- Allow storing the history in a database or log file
- Allow tracking who, what, when a modification occurred
- Allow knowing what the old and the new value are
Getting Started
To use the audit feature, you need to enable it and provide a list of the AuditEntry that will be populated during the operations.
// Execute List<AuditEntry> auditEntries = new List<AuditEntry>(); using (var bulk = new BulkOperation(connection)) { bulk.DestinationTableName = "Customer"; bulk.UseAudit = true; bulk.BulkMerge(list); auditEntries = bulk.AuditEntries; }
Try it: .NET Core | .NET Framework
Scenarios
- Saving audit history in a database
- Saving the audit history in a log file
Options
| Name | Description | 
|---|---|
| UseAudit | Gets or sets the UseAuditproperty. When theUseAuditproperty istrue, the AuditEntries property stores auditing metadata aboutINSERTED,UPDATED, andDELETEDrows and values. | 
| AuditEntries | Gets or sets the AuditEntriesproperty. TheAuditEntriesproperty stores auditing metadata aboutINSERTED,UPDATED, andDELETEDrows and values. This option requires to set the UseAudit property totrue. | 
Methods
| Name | Description | 
|---|---|
| AuditMode | The AuditModemethod allows you to exclude or include properties from the auditing. | 
Entities
| Name | Description | 
|---|---|
| AuditActionType | The AuditActionTypeenum represents the action that has been performed (Delete, Insert or Update). | 
| AuditEntry | The AuditEntryclass represents the auditing row metadata that has been modified. | 
| AuditEntryItem | The AuditEntryItemclass represents the auditing value metadata of a row that has been modified. | 
| AuditModeType | The AuditModeTypeenum represents if all properties should be included or excluded from the auditing. The default value isAuditModeType.IncludeAll. | 
| ColumnMappingAuditModeType | The ColumnMappingAuditModeTypeenum represents if a specific property should be included or excluded from the auditing. The default value isColumnMappingAuditModeType.Inherit. | 
FAQ
Why enabling this option decreases the performance?
When enabling this option, additional SQL are required such as returning all old and new values.