Skip to content

Generate ITenantScope for tenant-aware .Biz.cs entities - #97

Draft
nygula with Copilot wants to merge 2 commits into
masterfrom
copilot/feature-automatically-implement-itenant-scope
Draft

Generate ITenantScope for tenant-aware .Biz.cs entities#97
nygula with Copilot wants to merge 2 commits into
masterfrom
copilot/feature-automatically-implement-itenant-scope

Conversation

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

EntityBuilder already injects TenantInterceptor when a table contains TenantId, but generated business classes did not also implement ITenantScope. This change aligns the generated type declaration with the existing interceptor behavior for multi-tenant entities.

  • Generator behavior

    • Update XCode/Code/EntityBuilder.cs so GetBaseClass() appends ITenantScope only for business-class generation (.Biz.cs) when the table has a TenantId column.
    • Keep matching case-insensitive.
    • Avoid duplicating ITenantScope if it is already present in the configured base/interface list.
    • Leave data-class generation (.cs) unchanged.
  • Generated fixtures

    • Refresh affected generated business snapshots for tenant-aware entities:
      • 部门.Biz.cs
      • 角色.Biz.cs
      • 租户关系.Biz.cs
  • Focused coverage

    • Add a targeted generator test covering:
      • tenant-aware business entity => Entity<T>, ITenantScope
      • non-tenant data entity => no automatic ITenantScope

Example generated declaration:

public partial class Role : Entity<Role>, ITenantScope
{
    static Role()
    {
        Meta.Interceptors.Add<TenantInterceptor>();
    }
}

Co-authored-by: nygula <13066114+nygula@users.noreply.github.com>
Copilot AI changed the title [WIP] Add automatic implementation of ITenantScope in Biz.cs Generate ITenantScope for tenant-aware .Biz.cs entities Aug 14, 2026
Copilot AI requested a review from nygula August 14, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] XCodeTool 自动生成多租户表时,Biz.cs 应默认实现 ITenantScope 接口

2 participants