Open Closed

How to add a custom data filter to a customer table based on a custom property in abpuser entity #1786


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

Hello,

I added a custom property to abpuser entity by followinf this link: https://community.abp.io/articles/how-to-add-custom-property-to-the-user-entity-6ggxiddr The name of the custom property is "CustomerId", I need to create a filter on entity "Customer" to show only records related to CustomerId of the current user.

I think this is a very commun request but I haven't figure out how to do this using abp commercial framework.

Is there a tutorial somewhere to do this?

Any help providing detailed information will be appreciated.

Thanks,


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

    Hi,

    Yes we can do that,

    You need store custom property as a table field. see https://docs.abp.io/en/abp/latest/Entities#how-is-it-stored

    For filter see https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.ef.property?view=efcore-5.0

  • User Avatar
    0
    nparejod created

    Maybe, I didn't ask the question properly. I need to make a custome property visible inside "CurrentUser" in order to use it as a filter. I need to know how to get information of a custome property in abpuser throught "IcurrentUser" to use as a filter.

    I was told that I need to add the information to a claim to be able to extract it using CurrentUser, is there a tutorial to do that?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    Of course you can.

    See the unit tests, https://github.com/abpframework/abp/blob/48c52625f4c4df007f04d5ac6368b07411aa7521/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory_Tests.cs#L45

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