XXXHttpApiHostModule 里面默认启用多租户
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); 。。。 if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); }
增加多租户很简单,domain类里实现IMultiTenant接口就可以了
Customer : FullAuditedAggregateRoot<Guid>, IMultiTenant
在浏览器标头可以看到
public async Task<List<Customer>> GetListAsync(int maxResultCount = 10, int skipCount = 0, string filter=null) { return await (await GetDbSetAsync()) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter)) .OrderByDescending(e => e.CreationTime) .PageBy(skipCount, maxResultCount) .ToListAsync(); }
不能这样写
//unable to cast object of type //'microsoft.entityframeworkcore.query.internal.entityqueryable`1[fox.erp.domain.customer]' //to type 'microsoft.entityframeworkcore.dbset`
.WhereIf(!filter.IsNullOrWhiteSpace(), (Customer x) => x.Name.Contains(filter))
不要在Domain 项目里的CustomerManager.cs里的UpdateAsync 加上TenantId字段,这个由系统维护!!!
也不需要在DTO里维护!!!
标签:vnext,filter,domain,租户,pro,abp,int,IsNullOrWhiteSpace From: https://www.cnblogs.com/zitjubiz/p/17604125.html