खुला हुआ बंद किया हुआ

Updating TenantId of AbpUser #5801


User avatar
0
ademaygun बनाया था
  • ABP Framework version: v7.3.2
  • UI Type: Angular
  • Database System: EF Core
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace: The property or indexer 'IdentityUser.TenantId' cannot be used in this context because the set accessor is inaccessible.
  • Steps to reproduce the issue:

I want to update the tenantId of the user in the IdentityUser(AbpUser) table, but the TenantId setter is written as "protected." Is there a way for me to update the user's tenantId ?

var user = await userRepository.GetAsync(userId);
            user.TenantId = newTenantId; //compile error -> The property or indexer 'IdentityUser.TenantId' cannot be used in this context because the set accessor is inaccessible.


2 उत्तर (ओं)
  • User Avatar
    1
    maliming बनाया था
    सहायता दल Fullstack Developer

    hi

            ObjectHelper.TrySetProperty(
                user,
                x => x.TenantId,
                () => tenantId
            );
    
    
  • User Avatar
    0
    ademaygun बनाया था

    Hi @maliming,

    The code you provided worked, thank you very much for your support

Made with ❤️ on ABP v8.2.0-preview Updated on मार्च 25, 2024, 15:11