DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures.
$ dotnet add package DKNet.EfCore.AbstractionsCore abstractions and interfaces for Entity Framework Core applications implementing Domain-Driven Design (DDD) patterns. This package provides essential base classes, interfaces, and attributes for building robust data access layers with auditing, events, and entity management capabilities.
Install via NuGet Package Manager:
dotnet add package DKNet.EfCore.AbstractionsOr via Package Manager Console:
Install-Package DKNet.EfCore.Abstractionsusing DKNet.EfCore.Abstractions.Entities;
public class Product : Entity<Guid>
{
public Product(string name, decimal price, string createdBy)
: base(Guid.NewGuid(), createdBy)
{
Name = name;
Price = price;
}
public string Name { get; private set; }
public decimal Price { get; private set; }
public void UpdatePrice(decimal newPrice, string updatedBy)
{
Price = newPrice;
SetUpdatedBy(updatedBy);
}
}using DKNet.EfCore.Abstractions.Entities;
public class Customer : AuditEntity<int>
{
public Customer(string name, string email, string createdBy)
: base(createdBy)
{
Name = name;
Email = email;
}
public string Name { get; private set; }
public string Email { get; private set; }
// Inherits: CreatedBy, CreatedOn, UpdatedBy, UpdatedOn
}using DKNet.EfCore.Abstractions.Entities;
public class Document : Entity<Guid>, ISoftDeletableEntity
{
public Document(string title, string createdBy) : base(Guid.NewGuid(), createdBy)
{
Title = title;
}
public string Title { get; private set; }
public bool IsDeleted { get; private set; }
public DateTimeOffset? DeletedOn { get; private set; }
public string? DeletedBy { get; private set; }
public void SoftDelete(string deletedBy)
{
IsDeleted = true;
DeletedOn = DateTimeOffset.UtcNow;
DeletedBy = deletedBy;
}
}using DKNet.EfCore.Abstractions.Attributes;
[StaticData] // Marks as reference/static data
public class Category : Entity<int>
{
[Sequence(typeof(int))] // Auto-generate sequence values
public int Order { get; set; }
public string Name { get; set; }
}
[IgnoreEntity] // Exclude from EF discovery
public class TemporaryData
{
public string Value { get; set; }
}using DKNet.EfCore.Abstractions.Attributes;
public class Invoice : Entity<long>
{
[SqlSequence("invoice_number_seq", Schema = "billing")]
public long InvoiceNumber { get; set; }
public decimal Amount { get; set; }
}IEntity<TKey> - Basic entity contract with generic keyIAuditedProperties - Auditing properties (CreatedBy, CreatedOn, etc.)ISoftDeletableEntity - Soft deletion capabilitiesIEventEntity - Domain event managementIConcurrencyEntity - Optimistic concurrency controlEntity<TKey> - Generic entity base with event supportAuditEntity<TKey> - Entity with full audit trail capabilities[Sequence(Type)] - Generate sequential values for fields[SqlSequence(string)] - SQL-based sequence generation[StaticData] - Mark entity as static/reference data[IgnoreEntity] - Exclude entity from EF discoverypublic class Order : Entity<Guid>
{
public Order(string customerName, string createdBy) : base(Guid.NewGuid(), createdBy)
{
CustomerName = customerName;
Status = OrderStatus.Pending;
// Add domain event
AddEvent(new OrderCreatedEvent(Id, customerName));
}
public string CustomerName { get; private set; }
public OrderStatus Status { get; private set; }
public void Complete(string updatedBy)
{
Status = OrderStatus.Completed;
SetUpdatedBy(updatedBy);
// Add domain event
AddEvent(new OrderCompletedEvent(Id));
}
}
public record OrderCreatedEvent(Guid OrderId, string CustomerName);
public record OrderCompletedEvent(Guid OrderId);public class CustomAuditEntity : Entity<Guid>, IAuditedProperties
{
protected CustomAuditEntity(string createdBy) : base(Guid.NewGuid(), createdBy)
{
CreatedBy = createdBy;
CreatedOn = DateTimeOffset.UtcNow;
}
public string CreatedBy { get; protected set; }
public DateTimeOffset CreatedOn { get; protected set; }
public string? UpdatedBy { get; protected set; }
public DateTimeOffset? UpdatedOn { get; protected set; }
protected void SetUpdatedBy(string updatedBy)
{
UpdatedBy = updatedBy;
UpdatedOn = DateTimeOffset.UtcNow;
}
}public class AggregateRoot : Entity<Guid>
{
protected AggregateRoot(string createdBy) : base(Guid.NewGuid(), createdBy)
{
}
// Additional aggregate-specific behavior
// Event management, invariant enforcement, etc.
}The abstractions support full entity lifecycle management:
See the main CONTRIBUTING.md for guidelines on how to contribute to this project.
This project is licensed under the MIT License.
Part of the DKNet Framework - A comprehensive .NET framework for building modern, scalable applications.