afo*_*ank 6 entity-framework multi-tenant
我正在使用共享数据库和共享模式方法构建多租户应用程序.所以根据方法,我在每个表中都有"Tenant_Id"列.那么有没有办法在每个查询中自动附加where子句...
您可以使用围绕您的包装器来实现此目的DbContext,并使用where子句覆盖每个实体集合.
public class WrapperContext : YourDBContext
{
public override DbSet<YourEntitity> YourEntities
{
get
{
return base.YourEntities.Where(t => t.Tenant_Id == someId);
}
set
{
base.YourEntities = value;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
935 次 |
| 最近记录: |