Skip to content

Question about Setting/Unsetting flags #21

Answered by alirezanet
GregFaaborg asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @GregFaaborg,
The issue lies with your base permission. Currently, you're using Permission.None, but you should use ~Permission.All to ensure the bit length covers all possible features. If you modify the method accordingly, it should resolve the problem.

  private Task SetRolesAsync()
  {
    List<ApplicationRoleDto> roles = [];
    var basePermission = (~Permission.All).ToUniqueId(); // this must the base-permission which has the max length 
    for (var i = 0; i < 5; i++)
    {
      roles.Add(new ApplicationRoleDto()
      {
        ApplicationRoleId = i,
        Name = $"Role{i}",
        Description = $"Descr{i}",
        Permission = basePermission
      });
    }

    _roles = r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GregFaaborg
Comment options

Answer selected by GregFaaborg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants