admin管理员组

文章数量:1122846

I am trying to stay as close as possible to the standard methods and services that the ABP framework uses. I have a Blazor page that needs to show a list of countries on a drop down for selection.

If I use the standard Interface and service examples provided by ABP, the list returned to the front-end only has 10 entries. I would like to return all the countries.

Also, the list that is returned is not alphabetical. Is there a way that I can get the data to be shown alphabetically on the front-end?

Here is the code for my interface:

using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;

namespace reborn.Countries
{
    public interface ICountryAppService :
        ICrudAppService<
            CountryDto,
            Guid,
            PagedAndSortedResultRequestDto,
            CreateUpdateCountryDto
            >
    {
    }
}

This is the standard code for the service:

using reborn.Currencies;
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;


namespace reborn.Countries
{
    public class CountryAppService :
        CrudAppService<
            Country,
            CountryDto,
            Guid,
            PagedAndSortedResultRequestDto,
            CreateUpdateCountryDto>,
        ICountryAppService
    {
        public CountryAppService(IRepository<Country, Guid> repository) : base(repository)
        {
        }
    }
}

My Blazor code to get the data:

using reborn.CompanySettings;
using Blazorise;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using reborn.Countries;
using Volo.Abp.Application.Dtos;

namespace reborn.Blazor.Client.Pages.CompanySettings
{
    public partial class CompanyCreate
    {
        protected Validations CreateValidationsRef;
        protected CreateUpdateCompanySettingsDto NewEntity = new();
        IReadOnlyList<CountryDto> countryList = new List<CountryDto>();

        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();
            LimitedResultRequestDto.DefaultMaxResultCount = 1000;
            var countries = await CountryAppService.GetListAsync(new PagedAndSortedResultRequestDto());

            countryList = countries.Items;
        }

        protected virtual async Task CreateEntityAsync()
        {
            try
            {
                var validate = true;
                if (CreateValidationsRef != null)
                {
                    validate = await CreateValidationsRef.ValidateAll();
                }
                if (validate)
                {
                    await CompanySettingsAppService.CreateAsync(NewEntity);
                    NavigationManager.NavigateTo("company");
                }
            }

            catch (Exception ex)
            { 
                await HandleErrorAsync(ex);
            }
        }
    }
}

本文标签: cHow to return a full list of data in ascending order using ABP servicesStack Overflow