why UnitOfWorkManagger.Current is null sometimes in using DisableFilter method?
See original GitHub issueI use this scenario in RoleManager class:
public class RoleManager : AbpRoleManager<Role, User>
{
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly ICacheManager _cacheManager;
private readonly IPermissionManager _permissionManager;
private readonly RoleStore _roleStore;
public RoleManager(
RoleStore store,
IEnumerable<IRoleValidator<Role>> roleValidators,
ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors,
ILogger<AbpRoleManager<Role, User>> logger,
IPermissionManager permissionManager,
ICacheManager cacheManager,
IUnitOfWorkManager unitOfWorkManager,
IRoleManagementConfig roleManagementConfig)
: base(
store,
roleValidators,
keyNormalizer,
errors,
logger,
permissionManager,
cacheManager,
unitOfWorkManager,
roleManagementConfig
)
{
_cacheManager = cacheManager;
_unitOfWorkManager = unitOfWorkManager;
_permissionManager = permissionManager;
_roleStore = store;
}
public override async Task<bool> IsGrantedAsync(int roleId, Permission permission)
{
var cacheItem = await GetRolePermissionCacheItemAsync(roleId);
return cacheItem.GrantedPermissions.Contains(permission.Name);
}
private async Task<RolePermissionCacheItem> GetRolePermissionCacheItemAsync(int roleId)
{
//take exception in current in belove code
using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
{
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Application.Current is null when calling from a unittest
I have a method that I'm trying to call from a unit test. This method will in real life be run from a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So this issue can be closed?
Because there is no unit of work.
You can make your method
protected virtual
and mark it as[UnitOfWork]
: