Search code examples
asp.netaspnetboilerplate

How to query the AbpUserAccounts Table


I am trying to query the AbpUserAccounts table but there does not seems to be a way to perform crud operations on AbpUserAccounts. There is a User Manager but all of its functionalities points to AbpUsers.

I tried to create a new class but since its generated by Abp i dont think i can fetch it this way

namespace HCA.Users
{
    public class UserAccountAppService : AsyncCrudAppService<UserAccount, UserAccountDto>
    {
        private readonly UserManager _userManager;

        private readonly IRepository<UserAccount> _repository;

        public UserAccountAppService(IRepository<UserAccount> repository, UserManager userManager)
            : base(repository)
        {
            _repository = repository;
            _userManager = userManager;
        }

        public async Task<List<UserAccountDto>> GetAllUserAccounts()
        {
            var users = await _userManager.Users.ToListAsync();
            return ObjectMapper.Map<List<UserAccountDto>>(users);
        }
    }
}


Solution

  • Use IRepository<UserAccount, long>, since UserAccount is FullAuditedEntity<long>.

    Reference: src/Abp.Zero.Common/Authorization/Users/UserAccount.cs#L14