using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; 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) => queryable.FirstOrDefaultAsync(cancellationToken); public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) => queryable.FirstOrDefaultAsync(predicate, cancellationToken); public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default) => queryable.ToListAsync(cancellationToken); public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default) => queryable.CountAsync(); public Task LongCountAsync(IQueryable queryable, CancellationToken cancellationToken = default) => queryable.LongCountAsync(); public bool CanHandle(IQueryable queryable) => queryable.Provider is IAsyncQueryProvider; public Task AnyAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) => queryable.AnyAsync(predicate, cancellationToken); public Task AnyAsync(IQueryable queryable, CancellationToken cancellationToken = default) => queryable.AnyAsync(cancellationToken); } }