public static bool Any <TEntity>(this IRepository <TEntity> repository, Action <ISpecificationBuilder <TEntity> > specBuilder) where TEntity : class { var spec = new RelaySpecification <TEntity>(); specBuilder(spec.GetQuery()); return(repository.Any(spec)); }
public static async ValueTask <bool> AnyAsync <TEntity>(this IRepository <TEntity> repository, Func <ISpecificationBuilder <TEntity>, ValueTask> specBuilder) where TEntity : class { var spec = new RelaySpecification <TEntity>(); await specBuilder(spec.GetQuery()).ConfigureAwait(false); return(await repository.AnyAsync(spec).ConfigureAwait(false)); }
public static Task <TEntity> FirstOrDefaultAsync <TEntity>(this IRepository <TEntity> repository, Action <ISpecificationBuilder <TEntity> > specBuilder) where TEntity : class { var spec = new RelaySpecification <TEntity>(); specBuilder(spec.GetQuery()); return(repository.FirstOrDefaultAsync(spec)); }