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,
CancellationToken cancellationToken)
var spec = Spec.For<Product>(static p => p.IsActive)
& Spec.For<Product>(p => p.Price <= maxPrice);
return repository.FirstOrDefaultResultAsync(spec, cancellationToken);