예제 #1
0
    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));
    }
예제 #2
0
    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));
    }
예제 #3
0
    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));
    }