Linger.Audit
0.7.2
See the version list below for details.
dotnet add package Linger.Audit --version 0.7.2
NuGet\Install-Package Linger.Audit -Version 0.7.2
<PackageReference Include="Linger.Audit" Version="0.7.2" />
<PackageVersion Include="Linger.Audit" Version="0.7.2" />
<PackageReference Include="Linger.Audit" />
paket add Linger.Audit --version 0.7.2
#r "nuget: Linger.Audit, 0.7.2"
#:package Linger.Audit@0.7.2
#addin nuget:?package=Linger.Audit&version=0.7.2
#tool nuget:?package=Linger.Audit&version=0.7.2
Linger.Audit
A lightweight .NET auditing library that provides base classes and interfaces for entity auditing.
β¨ Features
- Multi-target framework support (.NET 9.0/.NET 8.0/.NET 6.0/NetStandard 2.0)
- Full audit trail tracking (creation, modification, deletion)
- Generic entity support with type-safe IDs
- Soft delete capability
- Built-in audit timestamps and user tracking
- Nullable reference types enabled
- MIT licensed
π¦ Installation
From Visual Studio
- Open the
Solution Explorer
. - Right-click on a project within your solution.
- Click on
Manage NuGet Packages...
. - Click on the
Browse
tab and search for "Linger.Audit". - Click on the
Linger.Audit
package, select the appropriate version and click Install.
Package Manager Console
PM> Install-Package Linger.Audit
.NET CLI Console
> dotnet add package Linger.Audit
π Quick Start
Basic Setup
// 1. Implement audit user provider
public class CurrentUserProvider : IAuditUserProvider
{
public string? UserName => "current-user";
public string GetUser() => UserName ?? "anonymous";
}
// 2. Create auditable entity
public class Product : FullAuditEntity
{
public string Name { get; set; } = default!;
public decimal Price { get; set; }
}
// The entity will track:
// - Creation time and creator
// - Last modification time and modifier
// - Deletion time and deleter
// - Soft delete status
Using with Dependency Injection
// Register in your DI container
services.AddSingleton<IAuditUserProvider, CurrentUserProvider>();
// Usage with Entity Framework Core
public class ApplicationDbContext : DbContext
{
private readonly IAuditUserProvider _auditUserProvider;
public ApplicationDbContext(
DbContextOptions<ApplicationDbContext> options,
IAuditUserProvider auditUserProvider) : base(options)
{
_auditUserProvider = auditUserProvider;
}
public override int SaveChanges()
{
UpdateAuditFields();
return base.SaveChanges();
}
private void UpdateAuditFields()
{
var entries = ChangeTracker.Entries().Where(e =>
e.State == EntityState.Added ||
e.State == EntityState.Modified ||
e.State == EntityState.Deleted);
foreach (var entry in entries)
{
if (entry.Entity is IAuditableEntity auditableEntity)
{
if (entry.State == EntityState.Added)
{
auditableEntity.CreationTime = DateTime.UtcNow;
auditableEntity.CreatorUserId = _auditUserProvider.GetUser();
}
else if (entry.State == EntityState.Modified)
{
auditableEntity.LastModificationTime = DateTime.UtcNow;
auditableEntity.LastModifierUserId = _auditUserProvider.GetUser();
}
}
if (entry.State == EntityState.Deleted && entry.Entity is ISoftDelete softDelete)
{
entry.State = EntityState.Modified;
softDelete.IsDeleted = true;
softDelete.DeletionTime = DateTime.UtcNow;
softDelete.DeleterUserId = _auditUserProvider.GetUser();
}
}
}
}
ποΈ Architecture
Linger.Audit provides the following key components:
IAuditUserProvider
- Interface for getting current userFullAuditEntity<T>
- Base class for entities with full audit trail and generic ID typeFullAuditEntity
- Base class for entities with full audit trail usingstring
ID typeAuditableEntity<T>
- Base class with creation/modification audit and generic ID typeAuditableEntity
- Base class with creation/modification audit usingstring
ID typeISoftDelete
- Interface for soft delete support
β Frequently Asked Questions
How to use custom ID types?
// Using Guid as ID type
public class Customer : FullAuditEntity<Guid>
{
public string Name { get; set; } = default!;
public string Email { get; set; } = default!;
}
// Using int as ID type
public class Order : FullAuditEntity<int>
{
public DateTime OrderDate { get; set; }
public decimal TotalAmount { get; set; }
}
How to use only partial auditing features?
// Only need creation and modification auditing
public class SimpleProduct : AuditableEntity
{
public string Name { get; set; } = default!;
}
// Only need soft delete functionality
public class Document : Entity, ISoftDelete
{
public string Title { get; set; } = default!;
public bool IsDeleted { get; set; }
public DateTime? DeletionTime { get; set; }
public string? DeleterUserId { get; set; }
}
π€ Contributing
Contributions are welcome! If you have feature requests, bug reports, or pull requests, please feel free to submit them on our GitHub repository.
π License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Linger.Audit:
Package | Downloads |
---|---|
Linger.EFCore.Audit
An Entity Framework Core audit trail library for automatically tracking data changes. Captures entity creation, modification, and deletion events with old and new values. Provides configurable audit logging with support for user tracking and timestamping. |
|
Linger.Audit.EFCore
C# Helper Library |
|
Linger.Repository.Contracts
C# Helper Library |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.9.0-preview | 56 | 9/12/2025 |
0.8.5-preview | 151 | 8/31/2025 |
0.8.4-preview | 267 | 8/25/2025 |
0.8.3-preview | 130 | 8/20/2025 |
0.8.2-preview | 168 | 8/4/2025 |
0.8.1-preview | 96 | 7/30/2025 |
0.8.0-preview | 534 | 7/22/2025 |
0.7.2 | 163 | 6/3/2025 |
0.7.1 | 160 | 5/21/2025 |
0.7.0 | 154 | 5/19/2025 |
0.6.0-alpha | 166 | 4/28/2025 |
0.5.0-alpha | 162 | 4/10/2025 |
0.4.0-alpha | 155 | 4/1/2025 |
0.3.3-alpha | 166 | 3/19/2025 |
0.3.2-alpha | 160 | 3/17/2025 |
0.3.1-alpha | 145 | 3/16/2025 |
0.3.0-alpha | 214 | 3/6/2025 |
0.2.0-alpha | 103 | 2/9/2025 |
0.1.2-alpha | 104 | 12/17/2024 |
0.1.1-alpha | 84 | 12/17/2024 |
0.1.0-alpha | 100 | 12/6/2024 |
0.0.3-alpha | 101 | 11/27/2024 |
0.0.2-alpha | 94 | 10/3/2024 |
0.0.1-alpha | 112 | 9/28/2024 |