Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications 1.0.0-preview.5

This is a prerelease version of Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications.
dotnet add package Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications --version 1.0.0-preview.5
                    
NuGet\Install-Package Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications -Version 1.0.0-preview.5
                    
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="Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications" Version="1.0.0-preview.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications" Version="1.0.0-preview.5" />
                    
Directory.Packages.props
<PackageReference Include="Tolitech.Infrastructure.Persistence.EntityFrameworkCore.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 Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications --version 1.0.0-preview.5
                    
#r "nuget: Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications, 1.0.0-preview.5"
                    
#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 Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications@1.0.0-preview.5
                    
#: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=Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications&version=1.0.0-preview.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications&version=1.0.0-preview.5&prerelease
                    
Install as a Cake Tool

Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications

A .NET library providing a foundational implementation of the Specification pattern for Entity Framework Core. It enables flexible, reusable, and composable queries using specifications, supporting advanced filtering, dynamic ordering, projections, and pagination.

Features

  • Specification pattern for EF Core
  • Generic repository base with async methods
  • Dynamic ordering by property path (string)
  • Projections and advanced query composition
  • Paging, includes, and split queries support

Installation

Add the NuGet package to your project:

dotnet add package Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications

Getting Started

1. Create a Specification

Define a specification by inheriting from Specification<TEntity>:

using Tolitech.Specifications;

public class ActiveCustomersSpecification : Specification<Customer>
{
    public ActiveCustomersSpecification()
    {
        Where(c => c.IsActive);
        OrderBy(c => c.Name);
        Take(10); // Paging example
    }
}

2. Use the Repository

Inherit from the provided Repository<TEntity> base class:

using Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications;

public class CustomerRepository : Repository<Customer>
{
    public CustomerRepository(MyDbContext dbContext) : base(dbContext) { }
}

3. Query with Specifications

var spec = new ActiveCustomersSpecification();
var customers = await customerRepository.ToListAsync(spec, cancellationToken);

4. Projections and Dynamic Ordering

// Projection
var names = await customerRepository.ToListAsync(
    spec,
    c => c.Name,
    cancellationToken);

// Dynamic ordering by string
spec.OrderByAsString.Add("Name:DESC");

5. Advanced: Includes, Paging, Split Queries

public class CustomerWithOrdersSpecification : Specification<Customer>
{
    public CustomerWithOrdersSpecification()
    {
        Where(c => c.IsActive);
        Include(c => c.Orders);
        EnableSplitQuery();
        Skip(10);
        Take(10);
    }
}

Tolitech.Infrastructure.Persistence.EntityFrameworkCore.Specifications brings powerful, maintainable, and reusable querying to your EF Core repositories.

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.5 138 8/4/2025
1.0.0-preview.4 435 7/21/2025
1.0.0-preview.3 114 7/3/2025
1.0.0-preview.2 115 7/3/2025
1.0.0-preview.1 81 1/6/2025