You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue with data filtering in my application, specifically within the AsyncPeriodicBackgroundWorkerBase class. Despite explicitly disabling the IIsActive filter using dataFilter.Disable(), there are occasional instances where the IsActiveFilterEnabled property remains enabled, leading to unexpected behavior in the generated SQL queries.
Reproduction Steps
AsyncPeriodicBackgroundWorkerBase
`using (dataFilter.Disable())
{
var query = await configRepository.GetQueryableAsync();
_logger.LogInformation($"000003:{parmQuery.ToQueryString()}");
var ts = Task.Run(async () => await Test2());
}
private async Task<Guid?> Test2()
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dataFilter = scope.ServiceProvider.GetService();
var configNoticeAppService = scope.ServiceProvider.GetService();
using (dataFilter.Disable<IIsActive>())
{
var parmQuery = await _paramConfigRepository.GetQueryableAsync();
_logger.LogInformation($"000004:{parmQuery.ToQueryString()}");
return await configNoticeAppService.Testxx();
}
}
protected override Expression<Func<TEntity, bool>> CreateFilterExpression()
{
var expression = base.CreateFilterExpression();
if (typeof(IIsActive).IsAssignableFrom(typeof(TEntity)))
{
var isActiveFilter = e => !IsActiveFilterEnabled || EF.Property<bool>(e, "IsActive");
expression = expression == null
? isActiveFilter
: QueryFilterExpressionHelper.CombineExpressions(expression, isActiveFilter);
}
return expression;
}`
The problem arises when the generated SQL occasionally still includes the IsActive filter even though it was intended to be disabled within the critical sections of the code.
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
8.0.0
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
The text was updated successfully, but these errors were encountered:
Please try to Disable filter in Test2 method.
already Disabled
`
private async Task<Guid?> Test2()
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dataFilter = scope.ServiceProvider.GetService();
var configNoticeAppService = scope.ServiceProvider.GetService();
using (dataFilter.Disable<IIsActive>())
{
var parmQuery = await _paramConfigRepository.GetQueryableAsync();
_logger.LogInformation($"000004:{parmQuery.ToQueryString()}");
return await configNoticeAppService.Testxx();
}
}
}`
_logger.LogInformation($"000004:{parmQuery.ToQueryString()}");
Log:
000004:DECLARE @__ef_filter__p_0 bit = CAST(0 AS bit);
DECLARE @__ef_filter__p_1 bit = CAST(0 AS bit);
SELECT [p].[Id], [p].[Address]
FROM [ppmexParamConfigs] AS [p]
WHERE (@__ef_filter__p_0 = CAST(1 AS bit) OR [p].[IsDeleted] = CAST(0 AS bit)) AND (@__ef_filter__p_1 = CAST(1 AS bit) OR [p].[IsActive]))
Is there an existing issue for this?
Description
I'm encountering an issue with data filtering in my application, specifically within the AsyncPeriodicBackgroundWorkerBase class. Despite explicitly disabling the IIsActive filter using dataFilter.Disable(), there are occasional instances where the IsActiveFilterEnabled property remains enabled, leading to unexpected behavior in the generated SQL queries.
Reproduction Steps
AsyncPeriodicBackgroundWorkerBase
`using (dataFilter.Disable())
{
var query = await configRepository.GetQueryableAsync();
_logger.LogInformation($"000003:{parmQuery.ToQueryString()}");
var ts = Task.Run(async () => await Test2());
}
private async Task<Guid?> Test2()
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dataFilter = scope.ServiceProvider.GetService();
var configNoticeAppService = scope.ServiceProvider.GetService();
}`
AbpDbContext
`protected bool IsActiveFilterEnabled => DataFilter?.IsEnabled() ?? false;
protected override bool ShouldFilterEntity(IMutableEntityType entityType)
{
return typeof(IIsActive).IsAssignableFrom(typeof(TEntity)) ? true : base.ShouldFilterEntity(entityType);
}
protected override Expression<Func<TEntity, bool>> CreateFilterExpression()
{
var expression = base.CreateFilterExpression();
}`
The problem arises when the generated SQL occasionally still includes the IsActive filter even though it was intended to be disabled within the critical sections of the code.
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
8.0.0
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
The text was updated successfully, but these errors were encountered: