Project: Blazor Server, EntityFramework, V4.3.0
Please advise how to set the sort order of the items to DisplayName instead of the Guid.
This should be the default behaviour.
private IReadOnlyList<LookupDto<Guid?>> Users { get; set; } = new List<LookupDto<Guid?>>();
UsersNullable = (await XXXXAppService.GetAppUserLookupAsync(new LookupRequestDto { Filter = newValue })).Items;
Thank you.
4 Answer(s)
-
0
If your LookupRequestDto inherits from PagedAndSortedResultRequestDto you can use
Sorting
property to apply an order.private IReadOnlyList<LookupDto<Guid?>> Users { get; set; } = new List<LookupDto<Guid?>>(); UsersNullable = (await XXXXAppService.GetAppUserLookupAsync(new LookupRequestDto { Filter = newValue, Sorting = "UserName" })).Items;
And if you implement on your own the repository:
public async Task<PagedResultDto<LookupDto<Guid?>>> GetAppUserLookupAsync(PagedAndSortedResultRequestDto input) { var list = await UserRepository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, input.Sorting); return new PagedResultDto<LookupDto<Guid?>>( await UserRepository.GetCountAsync(), ObjectMapper.Map<List<AppUser>, List<LookupDto<Guid?>>(list) ); }
-
0
The code I inlucded in the question was auto generated by ABP suite. It is the code generated when a navigation property is included in the entity. You can see by the code naming convention that this is the case.
I don't want to implement another repsoitory or alter the automatically generated ABP suite code, can this be raised as an issue as it makes no sense to have no sort on LookupDto results. LookupDto only have two fields, Key (Guid) and DisplayName - the value is what the end user sees and therefore LookupDto should by default be sorted by the DisplayName.
Thank you
-
0
-
0
Thank you.
The query option is what will work for me.