Myth.Specification
3.0.0.2-preview
See the version list below for details.
dotnet add package Myth.Specification --version 3.0.0.2-preview
NuGet\Install-Package Myth.Specification -Version 3.0.0.2-preview
<PackageReference Include="Myth.Specification" Version="3.0.0.2-preview" />
<PackageVersion Include="Myth.Specification" Version="3.0.0.2-preview" />
<PackageReference Include="Myth.Specification" />
paket add Myth.Specification --version 3.0.0.2-preview
#r "nuget: Myth.Specification, 3.0.0.2-preview"
#:package Myth.Specification@3.0.0.2-preview
#addin nuget:?package=Myth.Specification&version=3.0.0.2-preview&prerelease
#tool nuget:?package=Myth.Specification&version=3.0.0.2-preview&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.3.0 | 98 | 2/1/2026 |
| 4.3.0-preview.3 | 50 | 2/1/2026 |
| 4.3.0-preview.2 | 141 | 12/22/2025 |
| 4.2.1-preview.1 | 622 | 12/2/2025 |
| 4.2.0 | 460 | 11/30/2025 |
| 4.2.0-preview.1 | 70 | 11/29/2025 |
| 4.1.0 | 371 | 11/27/2025 |
| 4.1.0-preview.3 | 140 | 11/27/2025 |
| 4.1.0-preview.2 | 137 | 11/27/2025 |
| 4.1.0-preview.1 | 143 | 11/26/2025 |
| 4.0.1 | 200 | 11/22/2025 |
| 4.0.1-preview.8 | 156 | 11/22/2025 |
| 4.0.1-preview.7 | 162 | 11/22/2025 |
| 4.0.1-preview.6 | 146 | 11/22/2025 |
| 4.0.1-preview.5 | 210 | 11/21/2025 |
| 4.0.1-preview.4 | 215 | 11/21/2025 |
| 4.0.1-preview.3 | 217 | 11/21/2025 |
| 4.0.1-preview.2 | 247 | 11/21/2025 |
| 4.0.1-preview.1 | 254 | 11/21/2025 |
| 3.0.0.2-preview | 151 | 12/10/2024 |