Myth.Specification
3.0.4-preview.13
See the version list below for details.
dotnet add package Myth.Specification --version 3.0.4-preview.13
NuGet\Install-Package Myth.Specification -Version 3.0.4-preview.13
<PackageReference Include="Myth.Specification" Version="3.0.4-preview.13" />
<PackageVersion Include="Myth.Specification" Version="3.0.4-preview.13" />
<PackageReference Include="Myth.Specification" />
paket add Myth.Specification --version 3.0.4-preview.13
#r "nuget: Myth.Specification, 3.0.4-preview.13"
#:package Myth.Specification@3.0.4-preview.13
#addin nuget:?package=Myth.Specification&version=3.0.4-preview.13&prerelease
#tool nuget:?package=Myth.Specification&version=3.0.4-preview.13&prerelease
Myth.Specification
It is a .NET library for constructing queries in a very readable way, keeping the business rules in mind.
⭐ Features
- Easy readability
- Easy writing
- Business rules ahead
- Simplified use
🔮 Usage
To use, the following pattern must be followed:
var spec = SpecBuilder<Entity>
.Create()
.And(...)
.Or(...)
.Not()
...
The main idea is that every bit of your filter is built with the business rule in mind.
Suppose I have a Person table and I need to filter people with a female gender identity, who are from generation Z and who live in city X.
To do this, I should create a static class with the creation of each part of this filter, as follows:
public static class PersonSpecifications {
public static ISpec<Person> IsGenerationX(this ISpec<Person> spec) {
return spec.And(person => person.Birthdate.Year >= 2000);
}
public static ISpec<Person> IsIdentifiedAsFemale(this ISpec<Person> spec) {
return spec.And(person => person.Gender == "female");
}
public static ISpec<Person> LivesOnCity(this ISpec<Person> spec, string city) {
return spec.And(person => person.Address.City == city);
}
}
And then when building my filter, search:
public class PersonService {
private IPersonRepository _personRepository;
...
public IEnumerable<Person> GetFemalePersonsOfGenerationXOfCityAsync( string city, CancellationToken cancellationToken ) {
var spec = SpecBuilder<Person>
.Create()
.IsGenerationX()
.IsIdentifiedAsFemale()
.LivesOnCity(city);
var result = _repository.SearchAsync(spec, cancellationToken);
return result;
}
}
So it's very clear that I'm looking for people with a female gender identity, from generation X and who live in the city I'm looking for.
🪄 Specifications
Specifications can be of three types and worked individually or in groups.
Applying all types can be done as follows:
var enumerable = Enumerable.Empty<Person>();
var spec = SpecBuilder<Person>
.Create()
.And(x => x.PersonId != null)
.Distinct()
.Order(x => x.Name)
.Order(x => x.Address)
.Skip(10)
.Take(10);
var result = enumerable
.Specify(spec)
.ToList();
🔽 Filters
Filters can be applied directly as follows:
var enumerable = Enumerable.Empty<Person>();
var spec = SpecBuilder<Person>
.Create()
.And(x => x.PersonId != null);
var result = enumerable
.Filter(spec)
.ToList();
The following filters are available:
AndAndIfOrOrIfNot
⬇️ Ordering
Ordering can be applied directly as follows:
var enumerable = Enumerable.Empty<Person>();
var spec = SpecBuilder<Person>
.Create()
.Order(x => x.Name);
var result = enumerable
.Sort(spec)
.ToList();
The following orderings are available:
OrderOrderDescending📃 Pagination and post processing
Paginations and post processing can be applied directly as follows:
var enumerable = Enumerable.Empty<Person>();
var spec = SpecBuilder<Person>
.Create()
.DistinctBy(x => x.Name)
.Skip(10)
.Take(10);
var result = enumerable
.Paginate(spec)
.ToList();
The following functions are available:
SkipTakeDistinctBy
| Product | Versions 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. |
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Myth.Specification:
| Package | Downloads |
|---|---|
|
Myth.Repository
Generic repository pattern interfaces with async support, specification integration, and pagination. Provides read/write separation, CRUD operations, and extensible repository contracts for clean data access architecture. |
|
|
Myth.Repository.EntityFramework
Entity Framework Core implementations of repository pattern with Unit of Work, specification support, expression handling, and transaction management for robust data access with EF Core. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.5-preview.3 | 38 | 11/4/2025 |
| 3.0.5-preview.2 | 38 | 11/4/2025 |
| 3.0.5-preview.1 | 37 | 11/4/2025 |
| 3.0.4 | 130 | 11/3/2025 |
| 3.0.4-preview.19 | 51 | 11/2/2025 |
| 3.0.4-preview.17 | 51 | 11/1/2025 |
| 3.0.4-preview.16 | 51 | 11/1/2025 |
| 3.0.4-preview.15 | 59 | 10/31/2025 |
| 3.0.4-preview.14 | 124 | 10/31/2025 |
| 3.0.4-preview.13 | 125 | 10/30/2025 |
| 3.0.4-preview.12 | 118 | 10/23/2025 |
| 3.0.4-preview.11 | 116 | 10/23/2025 |
| 3.0.4-preview.10 | 113 | 10/23/2025 |
| 3.0.4-preview.9 | 112 | 10/23/2025 |
| 3.0.4-preview.8 | 120 | 10/22/2025 |
| 3.0.4-preview.6 | 112 | 10/21/2025 |
| 3.0.4-preview.5 | 112 | 10/21/2025 |
| 3.0.4-preview.4 | 114 | 10/20/2025 |
| 3.0.4-preview.3 | 117 | 10/20/2025 |
| 3.0.4-preview.2 | 35 | 10/18/2025 |
| 3.0.4-preview.1 | 118 | 10/7/2025 |
| 3.0.3 | 235 | 8/30/2025 |
| 3.0.2 | 140 | 8/23/2025 |
| 3.0.2-preview.4 | 122 | 8/21/2025 |
| 3.0.2-preview.3 | 97 | 8/16/2025 |
| 3.0.2-preview.1 | 79 | 5/23/2025 |
| 3.0.1 | 3,361 | 3/12/2025 |
| 3.0.1-preview.2 | 156 | 3/11/2025 |
| 3.0.1-preview.1 | 88 | 2/5/2025 |
| 3.0.0.2-preview | 144 | 12/10/2024 |
| 3.0.0.1-preview | 183 | 6/29/2024 |
| 3.0.0 | 4,608 | 12/10/2024 |
| 3.0.0-preview | 176 | 6/28/2024 |
| 2.0.0.17 | 2,328 | 12/15/2023 |
| 2.0.0.16 | 14,785 | 12/15/2023 |
| 2.0.0.15 | 294 | 12/15/2023 |
| 2.0.0.11 | 5,629 | 8/11/2022 |
| 2.0.0.10 | 2,976 | 7/20/2022 |
| 2.0.0.9 | 3,080 | 7/15/2022 |
| 2.0.0.8 | 3,097 | 7/12/2022 |
| 2.0.0.7 | 3,019 | 6/20/2022 |
| 2.0.0.6 | 3,138 | 5/23/2022 |
| 2.0.0.5 | 3,107 | 5/18/2022 |
| 2.0.0 | 3,188 | 2/17/2022 |