Tolitech.Specifications 1.0.0-preview.3

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

Tolitech.Specifications

Overview

Tolitech.Specifications provides implementations and abstractions for the Specification pattern, enabling modular, reusable, and composable business rules in .NET applications.

Features

  • Base Specification Classes: Easily create specifications by inheriting from base classes.
  • Logical Composition: Combine specifications using logical operators (AND, OR, NOT) for complex business logic.
  • Declarative Business Logic: Express business rules in a clear, maintainable, and testable way.
  • Query Support: Includes support for query composition, sorting, paging, and includes for related entities.

Usage

Creating a Specification

public class LegalAgeSpecification : Specification<Person>
{
    public override Expression<Func<Person, bool>> ToExpression() => person => person.Age >= 18;
}

Composing Specifications

var legalAgeSpec = new LegalAgeSpecification();
var nameSpec = new NameSpecification("John");
var combinedSpec = legalAgeSpec.And(nameSpec);

Applying Specifications

Specifications can be used to filter collections or as part of repository queries:

var adults = people.Where(legalAgeSpec.ToExpression().Compile()).ToList();

Query Features

  • Includes: Specify related entities to include in queries.
  • OrderBy/OrderByDescending: Define sorting for query results.
  • Paging: Use Take and Skip for result pagination.

Example

var spec = new LegalAgeSpecification()
    .OrderBy(p => p.Name)
    .Take(10)
    .Skip(5);

var filtered = people.AsQueryable().Where(spec.ToExpression()).ToList();
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.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Tolitech.Specifications:

Package Downloads
Tolitech.Domain.Specifications

The Domain.Specifications repository provides a foundational implementation for the Specification pattern within the Clean Architecture context.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.3 16 7/21/2025
1.0.0-preview.2 122 7/3/2025
1.0.0-preview.1 82 12/7/2024