- ABP Framework version: v7.3.0
- UI Type: Blazor WASM
- Database System: EF Core (PostgreSQL, etc..)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
I need to implement a new datafilter called ICompany which will hold a guid for the current company a user has chosen. This filter needs to be used across several abp modules each with their own DBContext. What's the best way to implement this given my use case and how would I go about setting the CompanyId for this filter when a user changes the current company guid they are wanting to filter the data with.
public interface ICompany { Guid CompanyId { get; set; } }
Yes, I have look at the following documentation (https://abp.io/docs/latest/framework/infrastructure/data-filtering#defining-custom-filters), but this implies I need to do this for every DBContext in every module I create which seems like too much to accomplish this.
20 Answer(s)
-
0
Hi,
I appreciate this link and it contains some helpful information however, I still do not see how this would be applied to all my DBContext implementations across all my modules as I indicated in my initial message.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
Would I use the method in this link (https://abp.io/docs/latest/framework/data/entity-framework-core#replacedbcontext-attribute) to achieve my requirement of having all the other DBContext objects, across all my modules in my solution applying this new data filter?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
Also what's confusing to me is that the link you provided is not specific to a Blazor WASM project, so it's confusing to know which of the classes mentioned in the link your provided go into which project in our tiered solution structure. As a reminder we are running a Blazor WASM project hosted in the abp generated 'public' website module. If you could also demonstrate where these classes go in terms of which project.
Is it possible you can generate a sample project of how to do what I originally asked for but using a Blazor WASM project?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
This is what the current DBContext class is for my blazor app. I have not implemented the suggested changes from your post the details them out, but I don't want to have to make this change to all my other ABP generated modules in my solution. I asked previously if those other DB contexts ( ILanguageManagementDbContext, ISystemMaintenanceDbContext, IReportQuickDesignerDbContext and ISecurityDbContext) also need these changes or if just having the [ReplaceDBContext] negates that and you have not responded directly to that question.
I also asked if you could detail what projects each of the proposed changes in your post (https://abp.io/community/articles/switching-between-organization-units-i5tokpzt) as it's not clear which projects they should go so the project compiles correctly.
Again seeing an actual example of a tiered blazor WASM solution referencing an ABP Generated Module (with it's own DBContext) being referenced by this blazor wasm project would be helpful.
namespace CFDataSystems.StructureCloud.EntityFrameworkCore; [ConnectionStringName(StructureCloudDbProperties.HostConnectionStringName)] [ReplaceDbContext(typeof(IIdentityProDbContext))] [ReplaceDbContext(typeof(IIdentityDbContext))] [ReplaceDbContext(typeof(ISaasDbContext))] [ReplaceDbContext(typeof(ILanguageManagementDbContext))] [ReplaceDbContext(typeof(ISystemMaintenanceDbContext))] [ReplaceDbContext(typeof(IReportQuickDesignerDbContext))] [ReplaceDbContext(typeof(ISecurityDbContext))] public class StructureCloudDbContext : AbpDbContext<StructureCloudDbContext>, IStructureCloudDbContext, IIdentityProDbContext, IIdentityDbContext, ISaasDbContext, ILanguageManagementDbContext, ISystemMaintenanceDbContext, IReportQuickDesignerDbContext, ISecurityDbContext { //Custom Tables public DbSet<TenantInformation> TenantInformation { get; set; } public DbSet<Screen> Screens { get; set; } public DbSet<UserDashboard> UserDashboards { get; set; } public DbSet<UserInformation> UserInformation { get; set; } public DbSet<UserLaunch> UserLaunch { get; set; } public DbSet<Template> Template { get; set; } //Saas Tables public DbSet<Tenant> Tenants { get; set; } public DbSet<Edition> Editions { get; set; } public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; } //Itentity Tables public DbSet<IdentityUser> Users { get; set; } public DbSet<IdentityRole> Roles { get; set; } public DbSet<IdentityClaimType> ClaimTypes { get; set; } public DbSet<OrganizationUnit> OrganizationUnits { get; set; } public DbSet<IdentitySecurityLog> SecurityLogs { get; set; } public DbSet<IdentityLinkUser> LinkUsers { get; set; } public DbSet<IdentityUserDelegation> UserDelegations { get; } //Language tables public DbSet<Language> Languages { get; set; } public DbSet<LanguageText> LanguageTexts { get; set; } public DbSet<LocalizationResourceRecord> LocalizationResources { get; set; } public DbSet<LocalizationTextRecord> LocalizationTexts { get; set; } //System Maintenance Tables public DbSet<SystemMaintenance.Domain.Attributes.Attribute> Attribute { get; set; } public DbSet<DataView> Views { get; set; } public DbSet<ViewJoin> ViewJoins { get; set; } public DbSet<JoinField> JoinFields { get; set; } public DbSet<CalculatedField> CalculatedFields { get; set; } public DbSet<ReferencedField> ReferencedFields { get; set; } public DbSet<DataType> DataTypes { get; set; } public DbSet<DataSourceQuery> DataSourceQueries { get; set; } public DbSet<DataSourceHeader> DataSourceHeaders { get; set; } public DbSet<DataSourceDetail> DataSourceDetails { get; set; } public DbSet<DataSourceProcedure> DataSourceProcedures { get; set; } public DbSet<Application> Applications { get; set; } public DbSet<Procedure> Procedures { get; set; } public DbSet<MenuGroup> MenuGroups { get; set; } public DbSet<RaiqiHeader> RaiqiHeader { get; set; } public DbSet<RaiqiDetail> RaiqiDetails { get; set; } public DbSet<Parameter> Parameters { get; set; } public DbSet<SqlTables> SqlTables { get; set; } //Security Tables public DbSet<SecurityRole> SecurityRoles { get; set; } public DbSet<SecurityRoleProcedure> SecurityRoleProcedures { get; set; } public DbSet<UserSecurityRole> UserSecurityRoles { get; set; } public DbSet<SecurityRoleStructure> SecurityRolesStructure { get; set; } public DbSet<SecurityRoleStructureWithProcedures> SecurityRolesStructureWithProcedures { get; set; } public DbSet<UserPermissionView> UserPermissions { get; set; } public StructureCloudDbContext(DbContextOptions<StructureCloudDbContext> options) : base(options) { } protected override void OnModelCreating(ModelBuilder builder) { //base.OnModelCreating(builder); builder.SetMultiTenancySide(MultiTenancySides.Host); if (builder.IsHostDatabase()) { ConfigurDatabaseSettings(builder); } builder.HasDefaultSchema("public"); base.OnModelCreating(builder); } private void ConfigurDatabaseSettings(ModelBuilder builder) { AbpCommonDbProperties.DbTablePrefix = string.Empty; builder.ConfigurePermissionManagement(); builder.ConfigureSettingManagement(); builder.ConfigureBackgroundJobs(); builder.ConfigureIdentityPro(); builder.ConfigureFeatureManagement(); builder.ConfigureLanguageManagement(); builder.ConfigureAuditLogging(); //PaymentDbProperties.DbTablePrefix = string.Empty; //builder.ConfigurePayment(); builder.ConfigureOpenIddict(); SaasDbProperties.DbTablePrefix = string.Empty; builder.ConfigureSaas(); TextTemplateManagementDbProperties.DbTablePrefix = string.Empty; builder.ConfigureTextTemplateManagement(); builder.ConfigureBlobStoring(); builder.ConfigureGdpr(); //builder.ConfigureCmsKit(); //builder.ConfigureCmsKitPro(); builder.ConfigureHostTables(); StructureCloudDbProperties.DbSchema = "structurecloud_settings"; builder.ConfigureSystemMaintenance(); builder.ConfigureSecurity(); AccountsPayableDbProperties.DbSchema = "vision"; builder.ConfigureAccountsPayable(); AccountsReceivableDbProperties.DbSchema = "vision"; builder.ConfigureAccountsReceivable(); JobCostDbProperties.DbSchema = "vision"; builder.ConfigureJobCost(); WorkOrderDbProperties.DbSchema = "vision"; builder.ConfigureWorkOrders(); PurchaseOrderDbProperties.DbSchema = "vision"; builder.ConfigurePurchaseOrders(); builder.ConfigureReportQuickDesigner(); } }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
Your
StructureCloudDbContexthas already replaced some modules.You can add your custom data filter in
StructureCloudDbContext.https://abp.io/docs/latest/framework/infrastructure/data-filtering#entityframework-core
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I am asking you specific questions and you’re not answering them at all.
I’ve asked you to detail where the changes such as the interface class goes representing the data filter so that it can be added to domain classes in other tiered modules I’m referencing.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
I need to implement a new datafilter called ICompany which will hold a guid for the current company a user has chosen. This filter needs to be used across several abp modules each with their own DBContext. What's the best way to implement this given my use case
public interface ICompany { Guid CompanyId { get; set; } }- Add a new class library and define the
ICompanyinterface. - Use this class library in your modules. eg inherit
ICompanyin some entities of some modules. - Add your custom data filter in
StructureCloudDbContext.(https://abp.io/docs/latest/framework/infrastructure/data-filtering#entityframework-core) - https://abp.io/community/articles/switching-between-organization-units-i5tokpzt
how would I go about setting the CompanyId for this filter when a user changes the current company guid they are wanting to filter the data with.
How do your users change their
CompanyId? Where do you store theCompanyId? InCurrentUserClaims?This article stores the
OrganizationIdinIDistributedCacheand changes it in ASPNET CoremiddlewareMarkdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) - Add a new class library and define the
-
0
hi
I have got your project.
Can you share some steps to show the problem?
Or what code you don't understand? etc...
Then I will add a new code.
Thanks.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I created another ticket regarding this sample project. You need to address that one first.
Run the dbmigrator to create the db and then run the project and you’ll see the error with the blazor iui
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Frustrated beyond belief with you on this one. The original issue I'm having is with the custom data filter, so I created a new project for you to demonstrate using ABP Studio/ABP Suite. The generated solution Blazor's project does not run (if you ran it you'd see that), so I couldn't even test out the data filter aspect. So you only addressed the things I didn't implement to create a sample for you but you didn't even address anything related to the custom data filter.
So can I assume in the demo I created for you I've implemented everything correctly with the custom data filter or did you not even look at that part?
Again I'll mention again to you the generated solution from ABP tools DID NOT RUN after it was generated!!!! So any data filter code and other code I added after that fact I could not test because the base solution (blazor project) does not run!!!!!!
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
-
0
Ok, thank you. Now that I can run the project I could see the other things I had missing, but more importantly I can see the custom data filter now running as expected. I will make the changes to my enterprise solution so we can utilize the new custom data filter.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)





