BertoSoftware.DapperAuditContext
0.2.0-alpha
See the version list below for details.
dotnet add package BertoSoftware.DapperAuditContext --version 0.2.0-alpha
NuGet\Install-Package BertoSoftware.DapperAuditContext -Version 0.2.0-alpha
<PackageReference Include="BertoSoftware.DapperAuditContext" Version="0.2.0-alpha" />
<PackageVersion Include="BertoSoftware.DapperAuditContext" Version="0.2.0-alpha" />
<PackageReference Include="BertoSoftware.DapperAuditContext" />
paket add BertoSoftware.DapperAuditContext --version 0.2.0-alpha
#r "nuget: BertoSoftware.DapperAuditContext, 0.2.0-alpha"
#:package BertoSoftware.DapperAuditContext@0.2.0-alpha
#addin nuget:?package=BertoSoftware.DapperAuditContext&version=0.2.0-alpha&prerelease
#tool nuget:?package=BertoSoftware.DapperAuditContext&version=0.2.0-alpha&prerelease
DapperAuditContext
A simple collections of functions and method for CRUD operation in Dapper for generic item with an integrated audit system.
NOTE
This documentation is under development
Version
2025-05-16
0.2.0 - Alpha version
New feature
Added fluent configuration where you can configure the following options:
- Storage mode
- Custom log file name
- Custom table name
- Added username field in create script database
- Warning: Migration script is not yet been implemented, so you have to add manually a new user field into AuditTable
ALTER TABLE dbo.AuditTable ADD Username nvarchar(255) NULL
Example:
VB.NET
Imports System
Module Program
Sub Main(args As String())
DapperAuditContext.AuditSettings = AuditConfiguration.CreateNew.StoreMode(AuditStoreMode.File).Build
'Add new value into Person Table with an automatic audit trail, just use DapperAuditContext instead of DapperContext
Using ctx As New DapperAuditContext
Dim person As New Model.Person With {
.Name = "John",
.Surname = "Doe"
}
ctx.InsertOrUpdate(person)
'Changes a property after save
person.Surname = "Black"
'Saves the changes and adds a record in the control table with the difference between the previous save.
ctx.InsertOrUpdate(person)
End Using
End Sub
End Module
C#
using System;
class Program
{
static void Main(string[] args)
{
DapperAuditContext.AuditSettings = AuditConfiguration.CreateNew.StoreMode(AuditStoreMode.File).Build();
// Add new value into Person Table with an automatic audit trail, just use DapperAuditContext instead of DapperContext
using (var ctx = new DapperAuditContext())
{
var person = new Model.Person
{
Name = "John",
Surname = "Doe"
};
ctx.InsertOrUpdate(person);
// Changes a property after save
person.Surname = "Black";
// Saves the changes and adds a record in the control table with the difference between the previous save.
ctx.InsertOrUpdate(person);
}
}
}
2025-05-13
0.1.0 - Alpha version
How to use
- Add a reference to the DapperAuditContext project in your project.
- Add a using statement to the DapperAuditContext namespace in your code file.
- Create a new instance of the DapperAuditContext class, passing in your database connection string.
- Use the methods provided by the DapperAuditContext class to perform CRUD operations on your database.
- Dispose of the DapperAuditContext instance when you're done using it.
- Optionally, you can use the DapperAuditContext class to perform other database operations, such as executing raw SQL queries or stored procedures.
- You can use the Audit system to track changes to your data and generate audit logs.
Create a model
A simple data model
VB.NET
Imports Dapper.Contrib.Extensions
Namespace Model
<Table("Person")>
<Audit>
Public Class Person
<Key>
Public Property ID As Integer
Public Property Name As String
Public Property Surname As String
<Audit(False)>
Public Property Address As String
End Class
End Namespace
C#
using Dapper.Contrib.Extensions;
namespace Model
{
[Table("Person")]
[Audit]
public partial class Person
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
[Audit(false)]
public string Address { get; set; }
}
}
You can use Audit attribute on class or in single property to include or exclude trail, the default value is True, so is not necessary to specify a True value for all properties.
A simple use might look like this:
VB.NET
Imports System
Module Program
Sub Main(args As String())
'Add new value into Person Table without audit trail
Using ctx As New DapperContext
Dim person As New Model.Person With {
.Name = "John",
.Surname = "Doe"
.Address = "Street 23"
}
ctx.InsertOrUpdate(person)
End Using
'Add new value into Person Table with an automatic audit trail, just use DapperAuditContext instead of DapperContext
Using ctx As New DapperAuditContext
Dim person As New Model.Person With {
.Name = "John",
.Surname = "Doe"
.Address = "Street 23"
}
ctx.InsertOrUpdate(person)
'Changes a property after save
person.Surname = "Black"
'Saves the changes and adds a record in the control table with the difference between the previous save.
ctx.InsertOrUpdate(person)
End Using
End Sub
End Module
C#
internal static partial class Program
{
public static void Main(string[] args)
{
// Add new value into Person Table without audit trail
using (var ctx = new DapperContext())
{
var person = new Model.Person()
{
Name = "John",
Surname = "Doe"
Address = "Street 23"
};
ctx.InsertOrUpdate(person);
}
// Add new value into Person Table with an automatic audit trail, just use DapperAuditContext instead of DapperContext
using (var ctx = new DapperAuditContext())
{
var person = new Model.Person()
{
Name = "John",
Surname = "Doe"
Address = "Street 23"
};
ctx.InsertOrUpdate(person);
// Changes a property after save
person.Surname = "Black";
// Saves the changes and adds a record in the control table with the difference between the previous save.
ctx.InsertOrUpdate(person);
}
}
}
Dipendencies
- You have to install Dapper.Contrib and assign to a model the [Key] attribute on ID field
Note
- The InsertOrUpdate method works only if the ‘Key’ attribute has been set to a field of type integer.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- BertoSoftware.DapperContext (>= 0.2.0-alpha)
- CompareNETObjects (>= 4.83.0)
-
net8.0
- BertoSoftware.DapperContext (>= 0.2.0-alpha)
- CompareNETObjects (>= 4.83.0)
-
net9.0
- BertoSoftware.DapperContext (>= 0.2.0-alpha)
- CompareNETObjects (>= 4.83.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on BertoSoftware.DapperAuditContext:
| Package | Downloads |
|---|---|
|
BertoSoftware.DapperAuditContext.MySql
A simple collections of functions and method for CRUD operation in Dapper for generic item with an integrated audit system |
|
|
BertoSoftware.DapperAuditContext.SqlServer
A simple collections of functions and method for CRUD operation in Dapper for generic item with an integrated audit system |
|
|
BertoSoftware.DapperAuditContext.SQLite
A simple collections of functions and method for CRUD operation in Dapper for generic item with an integrated audit system |
|
|
BertoSoftware.DapperAuditContext.PostgreSQL
A simple collections of functions and method for CRUD operation in Dapper for generic item with an integrated audit system |
|
|
BertoSoftware.DapperAuditContext.Firebird
A simple collections of functions and method for CRUD operation in Dapper for generic item with an integrated audit system |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.1.1 | 104 | 2/10/2026 | |
| 1.1.0 | 169 | 2/3/2026 | |
| 1.0.4 | 164 | 1/27/2026 | |
| 1.0.3 | 256 | 10/21/2025 | |
| 1.0.2 | 255 | 10/20/2025 | |
| 1.0.1 | 308 | 6/13/2025 | |
| 1.0.0 | 398 | 6/10/2025 | |
| 0.6.0-rc1 | 323 | 5/29/2025 | |
| 0.5.0-beta | 334 | 5/25/2025 | |
| 0.4.3-beta | 322 | 5/22/2025 | |
| 0.4.2-beta | 315 | 5/21/2025 | |
| 0.4.1-beta | 321 | 5/21/2025 | |
| 0.4.0-beta | 322 | 5/20/2025 | |
| 0.3.2-alpha | 304 | 5/20/2025 | |
| 0.3.1-alpha | 308 | 5/20/2025 | |
| 0.3.0-alpha | 312 | 5/20/2025 | |
| 0.2.1-alpha | 332 | 5/16/2025 | |
| 0.2.0-alpha | 330 | 5/16/2025 | |
| 0.1.0-alpha1 | 364 | 5/13/2025 |
v0.2.0.0 apha
Added fluent configuration where you can configure the following options:
- Storage mode
- Custom log file name
- Custom table name