Starts in:
2 DAYS
2 HRS
4 MIN
7 SEC
Starts in:
2 D
2 H
4 M
7 S

Activities of "PerigisettiVenkateswaraRao"

  • ABP Framework version: v8.2.1
  • UI Type: Angular
  • Database System: EF Core (MySQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): Auth server separated angular
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I need to create a custom filter to filter my entity based on BranchId. The BranchId will be received as a List<long> from the request headers or parameters. Here's the approach I followed:

  1. Created IBranchEntity Interface:

    • Placed this interface in the Domain.Shared folder.
    • It includes a BranchId property, which I inherited in the relevant entity.
  2. Defined IBranchContext Interface:

    • This interface includes a CurrentBranchId property to store the branch ID.
    • Implemented the interface in a BranchContext class in the Http.Host project with the necessary logic.
  3. Entity Framework Filtering Logic:

    • Created a file in the EntityFramework folder to define filtering logic for entities.
  4. Service Registration:

    • Registered the IBranchContext in the HostModule.cs under the ConfigureServices method as follows:

      context.Services.AddHttpContextAccessor(); context.Services.AddScoped<IBranchContext, BranchContext>();

      
      
  5. Database Context Changes:

    • Updated the ClinicServiceDbContext constructor to accept the IBranchContext.
      private readonly IBranchContext _branchContext;
      
      public ClinicServiceDbContext(
          DbContextOptions&lt;ClinicServiceDbContext&gt; options,
          IBranchContext branchContext
      ) : base(options)
      {
          _branchContext = branchContext;
      }
      
      protected override void OnModelCreating(ModelBuilder builder)
      {
           base.OnModelCreating(builder);
      
           builder.ConfigureClinicService();
      
           builder.ConfigureBranchFilterForEntities(_branchContext);
      }
      

After implementing the above, the filter is correctly identifying entities with the BranchFilter when the application is initially loaded. However, it is not being triggered for subsequent requests.

Showing 1 to 1 of 1 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06