RavenDB-Specifications 1.0.0

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

RavenDB.Specifications 🚀

NuGet License: MIT

A robust library implementing the Specification Design Pattern specifically for RavenDB. Decentralize your business logic from data access infrastructure with reusable, testable, and combinable queries.

🚀 Key Features

Feature Description
Search Abstraction Automatically converts Contains criteria to RavenDB's .Search() API for optimized full-text matching.
Rich Operators Built-in support for Equal, NotEqual, GreaterThan, LessThan, In, Between, etc.
Logical Composition Easily combine multiple business rules using And, Or, and Not methods.
SQL-to-Spec Parse simple SQL-like strings into Specification objects for dynamic filtering.
RavenDB Native Deep integration with IAsyncDocumentSession and IDocumentSession.

🛠️ Usage Example

1. Define Business Rules

public class ActivePremiumProductsSpec : Specification<Product>
{
    public override Expression<Func<Product, bool>> ToExpression()
    {
        return p => p.IsActive && p.Price > 100;
    }
}

// Or use built-in ones:
var brandSpec = new EqualSpecification<Product>("Brand", "Dell");
var searchSpec = new ContainsSpecification<Product>("Name", "Monitor");

2. Combine and Execute

var finalSpec = brandSpec.And(searchSpec).Or(new ActivePremiumProductsSpec());

using var session = documentStore.OpenAsyncSession();
var results = await Queries<Product>
    .Filter(session, finalSpec)
    .ToListAsync();

🔍 SQL-to-Specification

Convert dynamic SQL filter strings into strongly-typed specifications. Supports AND, OR, NOT, IN, IS NULL, and LIKE (with % wildcards).

string sql = "Brand = 'Dell' AND (Price < 1000 OR Category IN ('Electronics', 'IT')) AND Name LIKE '%Monitor%'";
var spec = SqlToSpecificationConverter.Convert<Product>(sql);

var products = await Queries<Product>.Filter(session, spec).ToListAsync();

📦 Installation

dotnet add package RavenDB.Specifications

📄 License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 was computed.  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 90 2/24/2026

Initial release of RavenDB.Specifications.