Browse Source

Add CreateFilteredQueryAsync

pull/6809/head
Halil İbrahim Kalkan 5 years ago
parent
commit
c7f480d30e
  1. 26
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs
  2. 4
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs

26
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs

@ -62,7 +62,7 @@ namespace Volo.Abp.Application.Services
{
await CheckGetListPolicyAsync();
var query = CreateFilteredQuery(input);
var query = await CreateFilteredQueryAsync(input);
var totalCount = await AsyncExecuter.CountAsync(query);
@ -160,11 +160,35 @@ namespace Volo.Abp.Application.Services
/// methods.
/// </summary>
/// <param name="input">The input.</param>
[Obsolete("Override the CreateFilteredQueryAsync method instead.")]
protected virtual IQueryable<TEntity> CreateFilteredQuery(TGetListInput input)
{
return ReadOnlyRepository;
}
/// <summary>
/// This method should create <see cref="IQueryable{TEntity}"/> based on given input.
/// It should filter query if needed, but should not do sorting or paging.
/// Sorting should be done in <see cref="ApplySorting"/> and paging should be done in <see cref="ApplyPaging"/>
/// methods.
/// </summary>
/// <param name="input">The input.</param>
protected virtual async Task<IQueryable<TEntity>> CreateFilteredQueryAsync(TGetListInput input)
{
/* If user has overridden the CreateFilteredQuery method,
* we don't want to make breaking change in this point.
*/
#pragma warning disable 618
var query = CreateFilteredQuery(input);
#pragma warning restore 618
if (!ReferenceEquals(query, ReadOnlyRepository))
{
return query;
}
return await ReadOnlyRepository.GetQueryableAsync();
}
/// <summary>
/// Maps <typeparamref name="TEntity"/> to <typeparamref name="TGetOutputDto"/>.
/// It internally calls the <see cref="MapToGetOutputDto"/> by default.

4
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs

@ -80,12 +80,12 @@ namespace Volo.Abp.Application.Services
Repository = repository;
}
protected async override Task DeleteByIdAsync(TKey id)
protected override async Task DeleteByIdAsync(TKey id)
{
await Repository.DeleteAsync(id);
}
protected async override Task<TEntity> GetEntityByIdAsync(TKey id)
protected override async Task<TEntity> GetEntityByIdAsync(TKey id)
{
return await Repository.GetAsync(id);
}

Loading…
Cancel
Save