Myth.Specification
3.0.4-preview.14
See the version list below for details.
dotnet add package Myth.Specification --version 3.0.4-preview.14
NuGet\Install-Package Myth.Specification -Version 3.0.4-preview.14
<PackageReference Include="Myth.Specification" Version="3.0.4-preview.14" />
<PackageVersion Include="Myth.Specification" Version="3.0.4-preview.14" />
<PackageReference Include="Myth.Specification" />
paket add Myth.Specification --version 3.0.4-preview.14
#r "nuget: Myth.Specification, 3.0.4-preview.14"
#:package Myth.Specification@3.0.4-preview.14
#addin nuget:?package=Myth.Specification&version=3.0.4-preview.14&prerelease
#tool nuget:?package=Myth.Specification&version=3.0.4-preview.14&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 |
|---|---|---|
| 4.2.1-preview.1 | 611 | 12/2/2025 |
| 4.2.0 | 427 | 11/30/2025 |
| 4.2.0-preview.1 | 60 | 11/29/2025 |
| 4.1.0 | 184 | 11/27/2025 |
| 4.1.0-preview.3 | 127 | 11/27/2025 |
| 4.1.0-preview.2 | 128 | 11/27/2025 |
| 4.1.0-preview.1 | 131 | 11/26/2025 |
| 4.0.1 | 173 | 11/22/2025 |
| 4.0.1-preview.8 | 144 | 11/22/2025 |
| 4.0.1-preview.7 | 148 | 11/22/2025 |
| 4.0.1-preview.6 | 134 | 11/22/2025 |
| 4.0.1-preview.5 | 200 | 11/21/2025 |
| 4.0.1-preview.4 | 204 | 11/21/2025 |
| 4.0.1-preview.3 | 209 | 11/21/2025 |
| 4.0.1-preview.2 | 236 | 11/21/2025 |
| 4.0.1-preview.1 | 243 | 11/21/2025 |
| 4.0.0 | 401 | 11/20/2025 |
| 4.0.0-preview.3 | 342 | 11/19/2025 |
| 4.0.0-preview.2 | 87 | 11/15/2025 |
| 4.0.0-preview.1 | 112 | 11/15/2025 |
| 3.10.0 | 192 | 11/15/2025 |
| 3.0.5-preview.15 | 149 | 11/14/2025 |
| 3.0.5-preview.14 | 218 | 11/12/2025 |
| 3.0.5-preview.13 | 223 | 11/12/2025 |
| 3.0.5-preview.12 | 223 | 11/11/2025 |
| 3.0.5-preview.11 | 224 | 11/11/2025 |
| 3.0.5-preview.10 | 223 | 11/11/2025 |
| 3.0.5-preview.9 | 212 | 11/10/2025 |
| 3.0.5-preview.8 | 91 | 11/8/2025 |
| 3.0.5-preview.7 | 90 | 11/8/2025 |
| 3.0.5-preview.6 | 92 | 11/8/2025 |
| 3.0.5-preview.5 | 92 | 11/8/2025 |
| 3.0.5-preview.4 | 58 | 11/7/2025 |
| 3.0.5-preview.3 | 138 | 11/4/2025 |
| 3.0.5-preview.2 | 135 | 11/4/2025 |
| 3.0.5-preview.1 | 135 | 11/4/2025 |
| 3.0.4 | 243 | 11/3/2025 |
| 3.0.4-preview.19 | 76 | 11/2/2025 |
| 3.0.4-preview.17 | 74 | 11/1/2025 |
| 3.0.4-preview.16 | 74 | 11/1/2025 |
| 3.0.4-preview.15 | 69 | 10/31/2025 |
| 3.0.4-preview.14 | 133 | 10/31/2025 |
| 3.0.4-preview.13 | 133 | 10/30/2025 |
| 3.0.4-preview.12 | 126 | 10/23/2025 |
| 3.0.4-preview.11 | 125 | 10/23/2025 |
| 3.0.4-preview.10 | 121 | 10/23/2025 |
| 3.0.4-preview.9 | 118 | 10/23/2025 |
| 3.0.4-preview.8 | 126 | 10/22/2025 |
| 3.0.4-preview.6 | 118 | 10/21/2025 |
| 3.0.4-preview.5 | 118 | 10/21/2025 |
| 3.0.4-preview.4 | 119 | 10/20/2025 |
| 3.0.4-preview.3 | 122 | 10/20/2025 |
| 3.0.4-preview.2 | 41 | 10/18/2025 |
| 3.0.4-preview.1 | 124 | 10/7/2025 |
| 3.0.3 | 249 | 8/30/2025 |
| 3.0.2 | 155 | 8/23/2025 |
| 3.0.2-preview.4 | 127 | 8/21/2025 |
| 3.0.2-preview.3 | 101 | 8/16/2025 |
| 3.0.2-preview.1 | 80 | 5/23/2025 |
| 3.0.1 | 4,757 | 3/12/2025 |
| 3.0.1-preview.2 | 159 | 3/11/2025 |
| 3.0.1-preview.1 | 90 | 2/5/2025 |
| 3.0.0.2-preview | 147 | 12/10/2024 |
| 3.0.0.1-preview | 186 | 6/29/2024 |
| 3.0.0 | 4,622 | 12/10/2024 |
| 3.0.0-preview | 179 | 6/28/2024 |
| 2.0.0.17 | 2,342 | 12/15/2023 |
| 2.0.0.16 | 14,917 | 12/15/2023 |
| 2.0.0.15 | 307 | 12/15/2023 |
| 2.0.0.11 | 5,635 | 8/11/2022 |
| 2.0.0.10 | 2,985 | 7/20/2022 |
| 2.0.0.9 | 3,089 | 7/15/2022 |
| 2.0.0.8 | 3,105 | 7/12/2022 |
| 2.0.0.7 | 3,028 | 6/20/2022 |
| 2.0.0.6 | 3,146 | 5/23/2022 |
| 2.0.0.5 | 3,114 | 5/18/2022 |
| 2.0.0 | 3,197 | 2/17/2022 |