Open Closed

How to get username from CreatorId column value ? #2704


User avatar
0
sateesh@g1.com.my created
  • ABP Framework version: v4.2.2
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

How to get username from CreatorId for all records at a time ? Is there any sample code ?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    if I understand correctly, are you looking for something like this?

    private readonly IRepository<IdentityUser, Guid> _identityUserRepository;
    
    public async Task GetUserNamesByCreatorId()
    {
        var userNames= (await _identityUserRepository.GetListAsync(x => x.CreatorId == ...)).Select(x => x.UserName);
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    -1
    sateesh@g1.com.my created

    Hi,

    if I understand correctly, are you looking for something like this?

    private readonly IRepository<IdentityUser, Guid> _identityUserRepository; 
     
    public async Task GetUserNamesByCreatorId() 
    { 
        var userNames= (await _identityUserRepository.GetListAsync(x => x.CreatorId == ...)).Select(x => x.UserName); 
    } 
    

    Yes, but i need to get all records Creator name with single query execution

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    You need to custom a repository.

    public class MyIdentityUserRepository : EfCoreRepository<IIdentityDbContext, IdentityUser, Guid>, IMyIdentityUserRepository
    {
        //.....
    
        public async Task GetCreatorNamesAsync(Guid creatorId)
        {
            var dbContext = await GetDbContextAsync();
        
            var creatorNames = await (from creator in dbContext.Set<IdentityUser>()
                join user in dbContext.Set<IdentityUser>() on creator.Id equals user.CreatorId
                where user.CreatorId == creatorId
                select creator.Name).ToListAsync();
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 21, 2026, 06:18
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.