How do I use IMayHaveTenant?
I have my model
public class GroupCategory: Entity, IMayHaveTenant { public string MyProperty {get; set; public int? TenantID {get; set; } }
But when I use
_groupRepository.GetAllList ();
He does not return the records that do not have TenantID, ie TenantID == null
I tried to use Disable and Enable method
3 Answer(s)
-
0
If you disable mayhavetenant filter, then you get all data (like <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/User-Management#multi-tenancy">http://www.aspnetboilerplate.com/Pages/ ... ti-tenancy</a>). Did you logged in to the application with a tenant (what is AbpSession.TenantId value)?
-
0
Yes, my AbpSession.TenantId has value So to get the records with null tenant and tenant logged , I do this way?
using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant)) { //here get all register with tenantId == AbpSession.TenantId and Tenant null ? var groups = _groupRepository.GetAllList().Where(x => x.TenantId == AbpSession.TenantId); }
Is it correct that?
Why SaveChanges not set tenantId with IMayHaveTenant, I'm set in controller using AbpSession.TenantId, is correct?
Thanks
-
0
I haven't understand your last question. But.. Instead of disabling, use SetFilterParameter to switch to a different tenant. Default tenant is the current tenant already (AbpSession.TenantId). So, no point to disable filter and set it to current tenant. It's the default behaviour.