using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query.Internal; using PoweredSoft.Data.Core; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; namespace PoweredSoft.Data.EntityFrameworkCore { public class AsyncQueryableHandlerService : IAsyncQueryableHandlerService { public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default(CancellationToken)) => queryable.FirstOrDefaultAsync(cancellationToken); public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) => queryable.FirstOrDefaultAsync(predicate, cancellationToken); public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default(CancellationToken)) => queryable.ToListAsync(cancellationToken); public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default(CancellationToken)) => queryable.CountAsync(); public Task LongCountAsync(IQueryable queryable, CancellationToken cancellationToken = default(CancellationToken)) => queryable.LongCountAsync(); public bool CanHandle(IQueryable queryable) => queryable.Provider is IAsyncQueryProvider; public Task AnyAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) => queryable.AnyAsync(predicate, cancellationToken); public Task AnyAsync(IQueryable queryable, CancellationToken cancellationToken = default(CancellationToken)) => queryable.AnyAsync(cancellationToken); } }