Please, help me: How do I implement sorting for multi-lingual entities? I have a simple entity that implements IMultiLingualEntity. I just recognized sorting doesn't work (using GetAllPagedSortedAndFilteredInputDto). I tried playing around with pSortableColumn-value but can't figure it out. Is it even possible this way?
7 Answer(s)
-
0
Hi @alexanderpilhar
Could you share your app service code for getting the entity list ?
-
0
Hi @ismcagdas
Here's the code.
public async Task<IPagedResult<CategoryBackendDto>> GetAllPagedSortedAndFilteredAsync(GetAllPagedSortedAndFilteredInputDto input) { var query = _repCategories .GetAllIncluding(e => e.Translations) .WhereIf( input.IsActive != null, e => e.IsActive == input.IsActive ); var cntEntities = await query .CountAsync(); var lstEntities = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); return new PagedResultDto<CategoryBackendDto>( cntEntities, ObjectMapper.Map<List<CategoryBackendDto>>(lstEntities) ); }
-
0
BTW: Sorting works fine for other non-translated columns/properties.
-
1
Hi @alexanderpilhar
I don't know if EF supports sorting via a entity collection property. You can check EF's documentation for that. Even if it supports such a feature, I think sorting will be done after retrieving the entire list and it will cause a performance problem.
We have disabled sorting user list bye role column because of this purpose.
If you need it, I think it is better to use a raw sql query.
-
0
I see. Well, thank you for your answer @ismcagdas! I will go with disabling sorting on that column, too (since there is no request for that, yet).
-
0
Please, help me: How do I implement sorting for multi-lingual entities? We have a title of books which we are storing as arabic and english. Now I want to sort books by title. Help to find a solution.
-
0
Hi @ibtikar!
As @ismcagdas already stated you might consider using a raw sql query.