Open Closed

Disable DataFilter from HttpApi #5680


User avatar
0
andmattia created
  • ABP Framework version: v7.1.0

I've a case where I have api the host need to access to orders (all tenant) and tenat user only own data.

I know that is possible to do that in appliaction/domain but I need to add logic to all calls. My idea is create a second HttpApi and disable datafilter but it doesn't work.

I create a using with UnitOfOwrk and inside of this using a second using disable a data fitler for multitenant but on application service I see tha same GIUD fot unit off work but IMultitenat filtert have filter with IsEnable set to true.

Is it possibile disable filter on HttpApi and propagate to Application/Domain/EF?


4 Answer(s)
  • User Avatar
    0
    andmattia created

    Hi

    I follow the documentation but it doesn't work.

           public class MyBookService : AbpController
        {
            private readonly IDataFilter<IMultiTenant> _softDeleteFilter;
            private readonly IRepository<Book, Guid> _bookRepository;
    
            public MyBookService(
                IDataFilter<IMultiTenant> softDeleteFilter,
                IRepository<Book, Guid> bookRepository)
            {
                _softDeleteFilter = softDeleteFilter;
                _bookRepository = bookRepository;
            }
            
            [HttpGet]
            public async Task<List<Book>> GetAllBooksIncludingDeletedAsync()
            {
                //Temporary disable the IMultiTenantfilter
                using (_softDeleteFilter.Disable())
                {
                    return await _bookRepository.GetListAsync();
                }
            }
        }
    

    In my application class IMultiTenant is Enable but on HttpApi is disable

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Member

    Hi

    we have the following implementation which abp follows https://docs.abp.io/en/abp/latest/Best-Practices/Module-Architecture

    Create you controller in HttpApi.csproj Project implement and inject you ApplicationService .

    Create **ApplicationService ** in Application.csproj

    Create interface of the application service in Application.Shared.csproj

  • User Avatar
    0
    andmattia created

    Are you try this code in 7.1.0?

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Member

    Hi,

    Yes, can you share you Controller code and application service code?. i see that you have Abpcontroller extended by ApplicationService Class.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 20, 2025, 18:00