Guides & Recipes — EricksonLopez.Specification
Recipe 1: Keyset Seek Pagination (SeekAfter)
Section titled “Recipe 1: Keyset Seek Pagination (SeekAfter)”Avoid slow OFFSET scans on deep result sets (ADR-004) using SeekAfter with IComparable cursor keys (v2.0.0+).
Recipe 2: Operator Composition & ReadRepositoryResultExtensions
Section titled “Recipe 2: Operator Composition & ReadRepositoryResultExtensions”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); }}