 <p>I think your permission should be filtered by the role. Something like this :</p> <pre><code>var rolePermissions = new HashSet&lt;int&gt;(tDbContext.RoleDetail.Where(rd =&gt; rd.RoleId == role.RoleID).Select(rd =&gt; rd.PermissionId)); </code></pre> <p>Your passing the role to your function but don't even use it : PopulateAssignedPermissionData(Role role). If i understand properly the code, now the <code>allPermission</code> and the <code>rolePermissions</code> are the same.</p>