Open Closed

Need to add a property abpuser table and create a lookup to one of my tables #1678


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

Hello,

I just added a new property (CustomerId) to AbpUser class. But what I really need is a Navigation property in AbpUser to pick up customers in my Customer table. What is the best way to do that in ABP?

public class AppUser : FullAuditedAggregateRoot<Guid>, IUser
{
    public virtual Guid? TenantId { get; private set; }
    public virtual string UserName { get; private set; }
    public virtual string Name { get; private set; }
    public virtual string Surname { get; private set; }
    public virtual string Email { get; private set; }
    public virtual bool EmailConfirmed { get; private set; }
    public virtual string PhoneNumber { get; private set; }
    public virtual bool PhoneNumberConfirmed { get; private set; }

    **public virtual Guid? CustomerId { get; protected set; }**

    private AppUser()
    {
        
    }
}

8 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    The following docs will help you

    • https://docs.abp.io/en/abp/latest/Object-Extensions
    • https://docs.abp.io/en/abp/4.4/Module-Entity-Extensions#module-entity-extensions
    • https://community.abp.io/articles/how-to-add-custom-property-to-the-user-entity-6ggxiddr
  • User Avatar
    0
    nparejod created

    Thanks for your help. Second link worked for me. I have one more question: Will the new field "CustomerId" be available in current user information? https://docs.abp.io/en/abp/latest/CurrentUser

    I need to create a filter with that field to be applied to Customer entity, so I need the field to be extracted from CurrenUser, is that possible?

    Thanks,

    Nestor

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I need the field to be extracted from CurrenUser

    https://github.com/abpframework/abp/issues/42#issuecomment-576025862

  • User Avatar
    0
    nparejod created

    Hello, That solution doesn't work for me. I am not using Claims. I just want to make available a new field I created in AbpUsers entity inside CurrentUser.

    Please help!

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The ICurrentUser get info from current claims.

    You can add the CustomerId to the current claims then get it though ICurrentUser

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Security/System/Security/Principal/AbpClaimsIdentityExtensions.cs#L29

  • User Avatar
    0
    nparejod created

    Hello,

    I am still confused about adding CustomerId to current claims. I am new using this framework, I apology for my lack of experience, abp commercial is a really cool framework that I would like to learn how to use it. I have more questions:

    • If I use claims, how do I populate/assign the CustomerId to all users? I need to assign a different Customer Id to each user
    • Where should I create the class AbpClaimsIdentityExtensions? which project / folder?
    • Any code that shows how to extract CustomerId from current claims?
    • Any detailed documentation I can use?

    Thanks in advance for your help.

    Nestor

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can refer the unit tests: https://github.com/abpframework/abp/pull/8153/files#diff-d73ab7794fbad910dc395d2188bdf3692f9a312a4efa69cbdb5cf7be41129ee3R45

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 18, 2024, 05:54