<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa" -->

---
title: Specification vs Repository vs Query Object in .NET
description: A detailed comparison distinguishes three .NET design abstractions that are often conflated: Specification (a named predicate for domain criteria), Repository...
canonical: https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Specification vs Repository vs Query Object in .NET | daily.dev
og:description: A detailed comparison distinguishes three .NET design abstractions that are often conflated: Specification (a named predicate for domain criteria), Repository...
og:url: https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa
og:image: https://api.daily.dev/og/posts/HchXK0NaA.png
og:image:alt: Specification vs Repository vs Query Object in .NET
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Specification vs Repository vs Query Object in .NET

**[We Are .NET](https://daily.dev/sources/wearedotnet)** · 12 min read · 14 upvotes · 1 comments

## Summary

A detailed comparison distinguishes three .NET design abstractions that are often conflated: Specification (a named predicate for domain criteria), Repository (a persistence access boundary), and Query Object (a use-case-shaped retrieval result). It clarifies that Specification is not a Gang of Four pattern despite using Strategy or Composite internally, explains how validation and authorization are separate concerns from Specification, and offers a decision matrix for choosing the right abstraction based on responsibility rather than pattern popularity. Includes C# interface sketches and an FAQ section addressing common misconceptions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.devleader.ca/2026/08/29/specification-vs-repository-vs-query-object-in-net>

## Questions this post answers

### What is the difference between the Specification pattern and the Repository pattern in .NET?

A Specification names criteria and answers whether a candidate satisfies a condition, returning a bool, predicate, or criteria expression, and typically lives in domain or application code. A Repository mediates access to persisted domain objects through a collection-like interface, controlling execution and materialization, and lives in infrastructure behind an application-facing interface. A Repository can accept a Specification as input criteria.

_Developers weighing specification versus repository boundaries in .NET can find pattern comparisons like this on daily.dev._

### Is the Specification pattern part of the Gang of Four design patterns?

No, Specification is not one of the Gang of Four's 23 creational, structural, and behavioral patterns from the 1994 catalog Design Patterns: Elements of Reusable Object-Oriented Software. Its lineage instead comes from domain-driven design and enterprise application architecture, notably from Eric Evans and Martin Fowler. A specification implementation may use GoF patterns like Composite or Strategy internally without becoming part of the GoF catalog.

_Anyone tracing pattern lineage before defending a design choice can browse pattern breakdowns like this on daily.dev._

### When should I use a Query Object instead of a Specification in .NET?

Use a Query Object when the retrieval operation and result shape are the actual concept, such as loading a dashboard, a paged support queue, or a monthly summary involving projection, sorting, grouping, and pagination. Use a Specification when a named Boolean condition is the main concept and needs reuse across in-memory domain decisions. A modern query specification carrying ordering and pagination behaves more like a specialized Query Object than a pure predicate.

_Teams deciding between query objects and specifications for a use case can compare tradeoffs like these on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> Would you let a query object accept a reusable specification, or keep that composition inside the persistence layer so tenant filters can't be bypassed?

## Similar posts on daily.dev

- [Specification Pattern in C\#: A Practical Guide for Modern .NET](https://daily.dev/posts/specification-pattern-in-c-a-practical-guide-for-modern-net-rwptpwhx7) · We Are .NET · 8 upvotes · 1 comments
- [Refactoring the Database Layer: Replacing Query Scope Bloat with Repository/Query Objects](https://daily.dev/posts/refactoring-the-database-layer-replacing-query-scope-bloat-with-repository-query-objects-zxdlpyvol) · CodeCraft Diary · 3 upvotes · 2 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#c#](https://daily.dev/tags/c#), [#design-patterns](https://daily.dev/tags/design-patterns)

[View this post on daily.dev](https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Specification vs Repository vs Query Object in .NET","url":"https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa"},"datePublished":"2026-08-29T13:27:34.774Z","dateModified":"2026-09-13T21:36:16.689Z","description":"A detailed comparison distinguishes three .NET design abstractions that are often conflated: Specification (a named predicate for domain criteria), Repository...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bb967b2d77281ca9191d0538fa4b2ae4?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bb967b2d77281ca9191d0538fa4b2ae4?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"We Are .NET","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"We Are .NET","logo":"https://media.daily.dev/image/upload/s--BsnVOa3i--/f_auto/v1718347410/logos/wearedotnet","url":"https://daily.dev/sources/wearedotnet"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"architecture,c#,design-patterns","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"We Are .NET","item":"https://daily.dev/sources/wearedotnet"},{"@type":"ListItem","position":3,"name":"Specification vs Repository vs Query Object in .NET"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa","comment":[{"@type":"Comment","text":"Would you let a query object accept a reusable specification, or keep that composition inside the persistence layer so tenant filters can’t be bypassed?","datePublished":"2026-09-08T05:39:04.819Z","url":"https://daily.dev/posts/HchXK0NaA#c-LmumnNall","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/specification-vs-repository-vs-query-object-in-net-hchxk0naa#faq","mainEntity":[{"@type":"Question","name":"What is the difference between the Specification pattern and the Repository pattern in .NET?","acceptedAnswer":{"@type":"Answer","text":"A Specification names criteria and answers whether a candidate satisfies a condition, returning a bool, predicate, or criteria expression, and typically lives in domain or application code. A Repository mediates access to persisted domain objects through a collection-like interface, controlling execution and materialization, and lives in infrastructure behind an application-facing interface. A Repository can accept a Specification as input criteria. Developers weighing specification versus repository boundaries in .NET can find pattern comparisons like this on daily.dev."}},{"@type":"Question","name":"Is the Specification pattern part of the Gang of Four design patterns?","acceptedAnswer":{"@type":"Answer","text":"No, Specification is not one of the Gang of Four's 23 creational, structural, and behavioral patterns from the 1994 catalog Design Patterns: Elements of Reusable Object-Oriented Software. Its lineage instead comes from domain-driven design and enterprise application architecture, notably from Eric Evans and Martin Fowler. A specification implementation may use GoF patterns like Composite or Strategy internally without becoming part of the GoF catalog. Anyone tracing pattern lineage before defending a design choice can browse pattern breakdowns like this on daily.dev."}},{"@type":"Question","name":"When should I use a Query Object instead of a Specification in .NET?","acceptedAnswer":{"@type":"Answer","text":"Use a Query Object when the retrieval operation and result shape are the actual concept, such as loading a dashboard, a paged support queue, or a monthly summary involving projection, sorting, grouping, and pagination. Use a Specification when a named Boolean condition is the main concept and needs reuse across in-memory domain decisions. A modern query specification carrying ordering and pagination behaves more like a specialized Query Object than a pure predicate. Teams deciding between query objects and specifications for a use case can compare tradeoffs like these on daily.dev."}}]}
```

