DKNet.EfCore.Specifications 10.1.8

dotnet add package DKNet.EfCore.Specifications --version 10.1.8
                    
NuGet\Install-Package DKNet.EfCore.Specifications -Version 10.1.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DKNet.EfCore.Specifications" Version="10.1.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DKNet.EfCore.Specifications" Version="10.1.8" />
                    
Directory.Packages.props
<PackageReference Include="DKNet.EfCore.Specifications" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DKNet.EfCore.Specifications --version 10.1.8
                    
#r "nuget: DKNet.EfCore.Specifications, 10.1.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DKNet.EfCore.Specifications@10.1.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DKNet.EfCore.Specifications&version=10.1.8
                    
Install as a Cake Addin
#tool nuget:?package=DKNet.EfCore.Specifications&version=10.1.8
                    
Install as a Cake Tool

DKNet.EfCore.Specifications

The Specification pattern for EF Core, plus a runtime dynamic predicate builder — the flagship successor to the retired DKNet.EfCore.Repos. Encapsulate filter, include, and order-by logic in reusable Specification<TEntity> classes, and execute them through a single non-generic IRepositorySpec that serves every entity in your DbContext.

Install

dotnet add package DKNet.EfCore.Specifications
services.AddSpecRepo<AppDbContext>();

Features

  • Specification<TEntity> — filter (WithFilter), includes (AddInclude, single-level or Include/ThenInclude chains), and ordering (AddOrderBy/AddOrderByDescending, declared-sequence, mixed-direction) in one object.
  • IRepositorySpec — one injected, non-generic repository for reads (FirstAsync, ToListAsync, ToPagedListAsync, AnyAsync, CountAsync) and writes (AddAsync, UpdateAsync, SaveChangesAsync, BulkDeleteAsync, BeginTransactionAsync) driven entirely by the specification passed to each call.
  • Dynamic Predicate Builder (DynamicAnd/DynamicOr) — build EF Core predicates from (propertyName, Ops, value) triples for runtime-driven search filters, with automatic type/enum coercion, camelCase/snake_case/kebab-case property-name normalization, and fail-safe (silently-skipped) invalid input.
  • ModelSpecification<TEntity, TModel> — the same builders, projected straight to a DTO via Mapster.
  • Keyset (cursor) paginationAfterKeyset/BeforeKeyset, ToKeysetPageAsync, and streaming ToPageEnumerable for large result sets without Skip/Take scan cost.

Quick start

using LinqKit;
using DKNet.EfCore.Specifications.Definitions;
using DKNet.EfCore.Specifications.Dynamics;
using DKNet.EfCore.Specifications.Repositories;

public sealed class ProductSearchSpecification : Specification<Product>
{
    public ProductSearchSpecification(string? name, decimal? minPrice)
    {
        var predicate = CreatePredicate(p => p.IsActive);

        if (name is not null)
            predicate = predicate.DynamicAnd(nameof(Product.Name), Ops.Contains, name);

        if (minPrice is not null)
            predicate = predicate.DynamicAnd(nameof(Product.Price), Ops.GreaterThanOrEqual, minPrice);

        WithFilter(predicate);
        AddOrderBy(p => p.Name);
    }
}

public sealed class ProductService(IRepositorySpec repo)
{
    public Task<IList<Product>> SearchAsync(string? name, decimal? minPrice, CancellationToken ct) =>
        repo.ToListAsync(new ProductSearchSpecification(name, minPrice), ct);
}

.AsExpandable() is applied automatically when querying through IRepositorySpec — no extra wiring needed for the dynamic predicate above to translate to SQL.

Migration — namespace changes in this release

Root types were grouped into concern folders; the namespace of each moved type now ends with its folder name. This is an import-only source break: no type was renamed, removed, resignatured, or had its behaviour changed — update the using line and you're done.

Type Old namespace New namespace
Specification<TEntity>, ModelSpecification<TEntity, TModel>, OrderClause DKNet.EfCore.Specifications DKNet.EfCore.Specifications.Definitions
IRepositorySpec, IRepositorySpecFactory, IRepositorySpecProvider (+ their implementations) DKNet.EfCore.Specifications DKNet.EfCore.Specifications.Repositories
PageAsyncEnumerator DKNet.EfCore.Specifications DKNet.EfCore.Specifications.Paging

SpecSetup — the package's AddSpecRepo registration point — stays at DKNet.EfCore.Specifications. Dynamics/ and Extensions/ (including the ambient LinqKit-namespaced DynamicPredicateExtensions) are unchanged.

Learn more

Full feature guide, configuration, composition with other DKNet packages, and gotchas: https://github.com/baoduy/DKNet/blob/dev/docs/EfCore/DKNet.EfCore.Specifications.md

Migrating from DKNet.EfCore.Repos? See https://github.com/baoduy/DKNet/blob/dev/docs/EfCore/Migrating-Repos-To-Specifications.md

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DKNet.EfCore.Specifications:

Package Downloads
DKNet.EfCore.Repos

Package Description

DKNet.AspCore.Extensions

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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.1.8 0 8/21/2026
10.1.7 36 8/21/2026
10.1.6 40 8/21/2026
10.1.5 54 8/20/2026
10.1.4 48 8/20/2026
10.1.3 57 8/19/2026
10.1.2 57 8/19/2026
10.1.1 44 8/19/2026
10.0.36 82 8/18/2026
10.0.35 95 8/5/2026
10.0.34 86 8/5/2026
10.0.33 96 8/4/2026
10.0.32 233 8/3/2026
10.0.31 102 7/21/2026
10.0.30 107 7/21/2026
10.0.29 400 6/22/2026
10.0.27 161 5/22/2026
10.0.26 114 5/19/2026
10.0.25 368 3/27/2026
10.0.24 124 3/27/2026
Loading failed