Base solution for your next web application
Open Closed

Using Dynamic Filter #28


User avatar
0
mohamed emaish created

Could you till us how to use implemented DynamicFilter in Abp

Thank you

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

8 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    There are three filters defined (as static consts on the AbpDataFilter class):

    • "SoftDelete" for entities implement ISoftDelete
    • "MustHaveTenant" for entities implement IMustHaveTenant
    • "MayHaveTenant" for entities implement IMayHaveTenant

    You can inject IUnitOfWorkManager and use IUnitOfWorkManager.Current.DisableFilter(AbpDataFilter.SoftDelete) for example.

    I'm working on the system, I'll document it soon.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    mohamed emaish created

    what if i wanted to disable it in the app startup or enable/disable it in run time for the whole application

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    hikalkan created
    Support Team

    It's in the roadmap: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/427">https://github.com/aspnetboilerplate/as ... issues/427</a>

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    valeriy created

    Good day. How can I use dynamic Filter or disable it in migration, when I use dbContext? Thanks

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    hikalkan created
    Support Team

    If you have a DbContext, just simple use context.DisableFilter extension method. See docs: <a class="postlink" href="https://github.com/jcachat/EntityFramework.DynamicFilters">https://github.com/jcachat/EntityFramew ... micFilters</a>

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    valeriy created

    I set Configuration.MultiTenancy.IsEnabled = true and _userManager.LoginAsync with Tonent works But _dbContext.DisableAllFilters() doesn't work: exec sp_executesql N'SELECT TOP (1) [Extent1].[Id] AS [Id], [Extent1].[TenantId] AS [TenantId], [Extent1].[Name] AS [Name], [Extent1].[DisplayName] AS [DisplayName], [Extent1].[IsStatic] AS [IsStatic], [Extent1].[IsDefault] AS [IsDefault], [Extent1].[IsDeleted] AS [IsDeleted], [Extent1].[DeleterUserId] AS [DeleterUserId], [Extent1].[DeletionTime] AS [DeletionTime], [Extent1].[LastModificationTime] AS [LastModificationTime], [Extent1].[LastModifierUserId] AS [LastModifierUserId], [Extent1].[CreationTime] AS [CreationTime], [Extent1].[CreatorUserId] AS [CreatorUserId] FROM [dbo].[AbpRoles] AS [Extent1] WHERE ((([Extent1].[TenantId] IS NULL) AND (@DynamicFilterParam_MayHaveTenant_tenantId IS NULL)) OR (([Extent1].[TenantId] IS NOT NULL) AND ([Extent1].[TenantId] = @DynamicFilterParam_MayHaveTenant_tenantId)) OR (@DynamicFilterParam_MayHaveTenant_DynamicFilterIsDisabled IS NOT NULL)) AND (([Extent1].[IsDeleted] = @DynamicFilterParam_SoftDelete_IsDeleted) OR (@DynamicFilterParam_SoftDelete_DynamicFilterIsDisabled IS NOT NULL)) AND ([Extent1].[TenantId] = @p__linq__0) AND (N''Admin'' = [Extent1].[Name])',N'@DynamicFilterParam_MayHaveTenant_tenantId int,@DynamicFilterParam_MayHaveTenant_DynamicFilterIsDisabled bit,@DynamicFilterParam_SoftDelete_IsDeleted bit,@DynamicFilterParam_SoftDelete_DynamicFilterIsDisabled bit,@p__linq__0 int',@DynamicFilterParam_MayHaveTenant_tenantId=0,@DynamicFilterParam_MayHaveTenant_DynamicFilterIsDisabled=NULL,@DynamicFilterParam_SoftDelete_IsDeleted=0,@DynamicFilterParam_SoftDelete_DynamicFilterIsDisabled=NULL,@p__linq__0=1

    Please advise. Thanks

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    valeriy created

    I found a solution for my situation: I call _dbContext.InitializeDynamicFilters(); then _dbContext.SetFilterScopedParameterValue(AbpDataFilters.MustHaveTenant, true); _dbContext.SetFilterScopedParameterValue(AbpDataFilters.MayHaveTenant, true);

    And select from Users returns values.

    But why _dbContext.DisableAllFilters() doesn't work - for me it's question... Thanks

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Where are you calling BbContext methods? Because, it's encapsulated by ABP as default. Are you using in repository? Can you share the code?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)