CSharpEssentials.Entity
3.0.2
dotnet add package CSharpEssentials.Entity --version 3.0.2
NuGet\Install-Package CSharpEssentials.Entity -Version 3.0.2
<PackageReference Include="CSharpEssentials.Entity" Version="3.0.2" />
<PackageVersion Include="CSharpEssentials.Entity" Version="3.0.2" />
<PackageReference Include="CSharpEssentials.Entity" />
paket add CSharpEssentials.Entity --version 3.0.2
#r "nuget: CSharpEssentials.Entity, 3.0.2"
#:package CSharpEssentials.Entity@3.0.2
#addin nuget:?package=CSharpEssentials.Entity&version=3.0.2
#tool nuget:?package=CSharpEssentials.Entity&version=3.0.2
CSharpEssentials.Entity
CSharpEssentials.Entity provides a robust foundation for Domain-Driven Design (DDD) entities in .NET. It offers base classes for auditing, soft deletion, and domain event management, helping you build standard and maintainable domain models.
🚀 Features
- Audit Logging: Built-in tracking for
CreatedAt,CreatedBy,UpdatedAt, andUpdatedBy. - Soft Delete: Standardized soft deletion support via
SoftDeletableEntityBase. - Domain Events: Built-in container for raising and clearing domain events.
- Flexible Generics: Support for strongly-typed IDs (e.g.,
Guid,int,long).
📦 Installation
dotnet add package CSharpEssentials.Entity
🛠 Usage
1. Basic Entity
Inherit from EntityBase<TId> to get standard audit fields and ID management.
using CSharpEssentials.Entity;
public class Product : EntityBase<Guid>
{
public string Name { get; set; }
public Product(string name)
{
Id = Guid.NewGuid();
Name = name;
}
}
2. Soft Deletable Entity
Use SoftDeletableEntityBase<TId> to add soft delete capabilities (IsDeleted, DeletedAt, DeletedBy).
using CSharpEssentials.Entity;
public class User : SoftDeletableEntityBase<Guid>
{
public string Username { get; set; }
}
// Usage
var user = new User();
// Mark as deleted (doesn't remove from DB, just flags it)
user.MarkAsDeleted(deletedAt: DateTimeOffset.UtcNow, deletedBy: "Admin");
// Restore if needed
user.Restore();
3. Domain Events
Entities can raise events that can be dispatched later (e.g., by your persistence layer).
using CSharpEssentials.Entity;
using CSharpEssentials.Entity.Interfaces;
public record ProductCreated(Guid ProductId) : IDomainEvent;
public class Product : EntityBase<Guid>
{
public Product()
{
Id = Guid.NewGuid();
// Raise an event
Raise(new ProductCreated(Id));
}
}
// Accessing events (e.g., in EF Core SaveChanges)
foreach (var domainEvent in product.DomainEvents)
{
// Dispatch event...
}
product.ClearDomainEvents();
4. Domain Event Timing
Control when domain events are published relative to persistence using the [DomainEventTiming] attribute.
using CSharpEssentials.Entity;
// Published after the database transaction commits (default)
public record OrderCreatedEvent(Guid OrderId) : IDomainEvent;
// Published before the transaction commits — use for validation
[DomainEventTiming(DomainEventTiming.BeforeSave)]
public record OrderValidationEvent(Guid OrderId) : IDomainEvent;
5. Auditing
The base classes expose methods to set audit info, typically called by your repository or DbContext.
var product = new Product("Laptop");
// Set creation info
product.SetCreatedInfo(DateTimeOffset.UtcNow, "User123");
// Set update info
product.SetUpdatedInfo(DateTimeOffset.UtcNow, "User456");
| 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 was computed. 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 is compatible. 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. net11.0 is compatible. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | 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.1
- CSharpEssentials.Results (>= 3.0.2)
- CSharpEssentials.Time (>= 3.0.2)
- Microsoft.Bcl.TimeProvider (>= 8.0.0)
- System.Text.Json (>= 9.0.0)
-
net10.0
- CSharpEssentials.Results (>= 3.0.2)
- CSharpEssentials.Time (>= 3.0.2)
-
net11.0
- CSharpEssentials.Results (>= 3.0.2)
- CSharpEssentials.Time (>= 3.0.2)
-
net9.0
- CSharpEssentials.Results (>= 3.0.2)
- CSharpEssentials.Time (>= 3.0.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CSharpEssentials.Entity:
| Package | Downloads |
|---|---|
|
CSharpEssentials
A comprehensive C# library enhancing functional programming capabilities with type-safe monads (Maybe, Result), discriminated unions (Any), and robust error handling. Features include: domain-driven design support, enhanced Entity Framework integration, testable time management, JSON utilities, and LINQ extensions. Built for modern C# development with focus on maintainability, testability, and functional programming principles. |
|
|
CSharpEssentials.EntityFrameworkCore
Enhances Entity Framework Core with functional programming patterns and DDD-friendly features. Includes base entity classes, soft delete support, audit trails, query filters, optimistic concurrency, PostgreSQL integration, query performance monitoring, and domain event handling. Perfect for building maintainable and scalable data access layers in modern .NET applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.2 | 0 | 5/5/2026 |
| 3.0.1 | 69 | 5/3/2026 |
| 3.0.0 | 68 | 5/3/2026 |
| 2.1.0 | 291 | 11/26/2025 |
| 2.0.9 | 259 | 9/30/2025 |
| 2.0.8 | 237 | 9/29/2025 |
| 2.0.7 | 239 | 9/29/2025 |
| 2.0.6 | 228 | 9/29/2025 |
| 2.0.5 | 240 | 9/29/2025 |
| 2.0.4 | 232 | 9/28/2025 |
| 2.0.3 | 230 | 9/28/2025 |
| 2.0.2 | 242 | 9/28/2025 |
| 2.0.1 | 230 | 9/28/2025 |
| 2.0.0 | 251 | 9/28/2025 |