Ir al contenido

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.

Guías y Recetas — EricksonLopez.Specification

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);
}
}