Ends in:
2 DAYS
18 HRS
11 MIN
44 SEC
Ends in:
2 D
18 H
11 M
44 S
Open Closed

How to access the data of UserRole from DbContext #824


User avatar
0
huy.quan created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v4.0.2
  • UI type: Angular
  • DB provider: EF Core
  • Identity Server Seperated (Angular): no

<br> I have a query need to check Role of User, I can get list of user by using DbContext.Users but also need to check role of each user from list. How can I do that? Is it possible to get UserRoles by something like DbContext.UserRoles?

Thanks support team


1 Answer(s)
  • User Avatar
    0
    cotur created

    Hi,

    There is an entity that named IdentityUserRole that represents the link between a user and a role.

    You can user IIdentityDbContext and get those by;

    var dbContext = await GetDbContextAsync();
    
    dbContext.Set<IdentityUserRole>().*******
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 02, 2024, 12:35