Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Guides & Recipes — EricksonLopez.Specification

Avoid slow OFFSET scans on deep result sets (ADR-004) using SeekAfter with IComparable cursor keys (v2.0.0+).

using System;
using System.Threading;
using System.Threading.Tasks;
using EricksonLopez.Result;
using EricksonLopez.Specification;
using EricksonLopez.Specification.Result;
namespace Example.SpecificationRecipes;
public sealed record Product(Guid Id, bool IsActive, decimal Price);
public static class ProductQueries
{
public static Task<Result<Product>> FindActiveAffordableAsync(
IReadRepository<Product> repository,
decimal maxPrice,
CancellationToken cancellationToken)
{
var spec = Spec.For<Product>(static p => p.IsActive)
& Spec.For<Product>(p => p.Price <= maxPrice);
return repository.FirstOrDefaultResultAsync(spec, cancellationToken);
}
}