finds.dev← search

// the find

ardalis/Specification

★ 2,266 · C# · MIT · updated Nov 2025

Base class with tests for adding specifications to a DDD model

A .NET library implementing the Specification pattern — encapsulates query predicates, includes, ordering, and paging into named, reusable objects instead of scattering lambdas across repositories. It ships a built-in EF Core RepositoryBase so you can drop it in without writing boilerplate. Best fit for teams already doing DDD who are tired of one-off repository methods multiplying.

The evaluator pipeline is genuinely extensible — you can add a custom evaluator (e.g. a QueryTag injector or a soft-delete filter) and plug it into SpecificationEvaluator without forking the library. The in-memory evaluator mirrors the EF Core one, so unit tests against fake collections exercise the same spec logic without a database. The separate EF6 and EF Core packages share the same core abstractions, meaning the pattern is consistent across legacy apps too. Benchmarks are included in the repo, which is more honest than most libraries — you can see the allocation cost of building and evaluating specs at different sizes.

The RepositoryBase forces you into its shape: if you need anything beyond the provided ListAsync/FirstAsync/CountAsync/AnyAsync surface, you're either adding extension methods or bypassing the abstraction entirely with raw DbContext access. The search feature (LIKE-based string matching applied in-memory for non-EF evaluators) is easy to misuse — it looks like a query feature but can silently pull too much data and filter client-side if you're not paying attention. There's no built-in support for projections at the specification level in a type-safe way; the Select builder takes an arbitrary expression but composing it with includes or post-processing actions gets messy fast. Version 9 introduced breaking changes significant enough to warrant a dedicated issue tracking them, so upgrading from v8 in a large codebase isn't a one-liner.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →