From fb6ecd0600288eea757bea63a8d3a60107a159b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= <30300440+bariscanyilmaz@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:46:23 +0300 Subject: [PATCH 1/3] give more details about list service filtering --- docs/en/UI/Angular/List-Service.md | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/en/UI/Angular/List-Service.md b/docs/en/UI/Angular/List-Service.md index fc3697bd35..5301222ca1 100644 --- a/docs/en/UI/Angular/List-Service.md +++ b/docs/en/UI/Angular/List-Service.md @@ -201,3 +201,38 @@ You may use observables in combination with [AsyncPipe](https://angular.io/guide ``` +ABP doesn't have a built-in filtering mechanism. You need to implement yourself and handle `filter` property in backend as seen in below. + +```cs +public class BookRequestDto : PagedAndSortedResultRequestDto +{ + public string Filter { get; set; } +} +``` +```cs +public interface IBookAppService : + ICrudAppService< //Defines CRUD methods + BookDto, //Used to show books + Guid, //Primary key of the book entity + BookRequestDto, //Used for paging/sorting + CreateUpdateBookDto> //Used to create/update a book +{ + +} +``` +```cs +//Override GetListAsync in BookAppService + +public override async Task> GetListAsync(BookRequestDto input) +{ + var query=await ReadOnlyRepository.GetQueryableAsync(); + query.WhereIf(!string.IsNullOrEmpty(input.Filter),x=>x.Name.Contains(input.Filter)); + + var totalCount = await AsyncExecuter.CountAsync(query); + var items = await AsyncExecuter.ToListAsync(query); + var entities = ObjectMapper.Map, List>(items); + + return new PagedResultDto(totalCount,entities); +} + +``` \ No newline at end of file From 2cd1e111e2fd9cd02ef24278f94446d8be8aa430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Thu, 2 Mar 2023 16:58:09 +0300 Subject: [PATCH 2/3] Update docs/en/UI/Angular/List-Service.md Co-authored-by: Qingxiao Ren --- docs/en/UI/Angular/List-Service.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/UI/Angular/List-Service.md b/docs/en/UI/Angular/List-Service.md index 5301222ca1..5b0234c502 100644 --- a/docs/en/UI/Angular/List-Service.md +++ b/docs/en/UI/Angular/List-Service.md @@ -225,8 +225,8 @@ public interface IBookAppService : public override async Task> GetListAsync(BookRequestDto input) { - var query=await ReadOnlyRepository.GetQueryableAsync(); - query.WhereIf(!string.IsNullOrEmpty(input.Filter),x=>x.Name.Contains(input.Filter)); + var queryable = await ReadOnlyRepository.GetQueryableAsync(); + var query = queryable.WhereIf(!string.IsNullOrEmpty(input.Filter), x => x.Name.Contains(input.Filter)); var totalCount = await AsyncExecuter.CountAsync(query); var items = await AsyncExecuter.ToListAsync(query); From 077a57dd6320a84fb8d311d7313ece6c5670a9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= <30300440+bariscanyilmaz@users.noreply.github.com> Date: Fri, 3 Mar 2023 14:50:53 +0300 Subject: [PATCH 3/3] doc: remove unrelated code detail --- docs/en/UI/Angular/List-Service.md | 36 +----------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/docs/en/UI/Angular/List-Service.md b/docs/en/UI/Angular/List-Service.md index 5b0234c502..2f0eb9fc57 100644 --- a/docs/en/UI/Angular/List-Service.md +++ b/docs/en/UI/Angular/List-Service.md @@ -201,38 +201,4 @@ You may use observables in combination with [AsyncPipe](https://angular.io/guide ``` -ABP doesn't have a built-in filtering mechanism. You need to implement yourself and handle `filter` property in backend as seen in below. - -```cs -public class BookRequestDto : PagedAndSortedResultRequestDto -{ - public string Filter { get; set; } -} -``` -```cs -public interface IBookAppService : - ICrudAppService< //Defines CRUD methods - BookDto, //Used to show books - Guid, //Primary key of the book entity - BookRequestDto, //Used for paging/sorting - CreateUpdateBookDto> //Used to create/update a book -{ - -} -``` -```cs -//Override GetListAsync in BookAppService - -public override async Task> GetListAsync(BookRequestDto input) -{ - var queryable = await ReadOnlyRepository.GetQueryableAsync(); - var query = queryable.WhereIf(!string.IsNullOrEmpty(input.Filter), x => x.Name.Contains(input.Filter)); - - var totalCount = await AsyncExecuter.CountAsync(query); - var items = await AsyncExecuter.ToListAsync(query); - var entities = ObjectMapper.Map, List>(items); - - return new PagedResultDto(totalCount,entities); -} - -``` \ No newline at end of file +ABP doesn't have a built-in filtering mechanism. You need to implement yourself and handle `filter` property in backend.