15 lines
657 B
C#
15 lines
657 B
C#
|
using OpenHarbor.CQRS.DynamicQuery.Abstractions;
|
||
|
|
||
|
namespace DigitalOps.Dal;
|
||
|
|
||
|
public class DefaultQueryableProvider<TEntity>(MainDbContext context, IServiceProvider serviceProvider) : IQueryableProvider<TEntity>
|
||
|
where TEntity : class
|
||
|
{
|
||
|
public Task<IQueryable<TEntity>> GetQueryableAsync(object query, CancellationToken cancellationToken = default)
|
||
|
{
|
||
|
if (serviceProvider.GetService(typeof(IQueryableProviderOverride<TEntity>)) is IQueryableProviderOverride<TEntity> queryableProviderOverride)
|
||
|
return queryableProviderOverride.GetQueryableAsync(query, cancellationToken);
|
||
|
|
||
|
return Task.FromResult(context.Set<TEntity>().AsQueryable());
|
||
|
}
|
||
|
}
|