Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Extending Data filters of a Tenant #6764


User avatar
0
mujthabagroad created

Hello,

We need to get the data from a table which is added under MustHaveTenant entity, some case we need to add data as a seed for all tenants with tenantid as ZERO. we need to get the data which comes under the logged in Tenantid as well as common data which we gave Id as ZERO.

How we can achieve this?

Thanks.


6 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, can you explain the use using more concrete examples?

    it might not be necessary to store seed data with tenant-id = 0 if you only need to seed data for all tenant

  • User Avatar
    0
    mujthabagroad created

    With Example:

    An Entity Book, we have some common books for all tenants, that should show for all tenant users. but also have tenant-specific books that should show only for that specific tenant user.

    In a lookup table should show the data which is common as well as specific tenant.

  • User Avatar
    0
    ryancyq created
    Support Team

    Do the common books fixed for all tenants?

    Also, do the common books change over time?

  • User Avatar
    0
    mujthabagroad created
    Do the common books fixed for all tenants?
    

    Yes, This is common seed for all tenant, we will add as seed in EF.

    Also, do the common books change over time?
    

    No.

  • User Avatar
    0
    aaron created
    Support Team

    Simply override CreateFilterExpression for IMayHaveTenant and/or IMustHaveTenant in your DbContext.

    Change ((IMayHaveTenant)e).TenantId == CurrentTenantId to (((IMayHaveTenant)e).TenantId == CurrentTenantId || (((IMayHaveTenant)e).TenantId == 0).

  • User Avatar
    0
    mujthabagroad created

    Hi @Aaron,

    Let me try on this way.

    Thnaks for the help.