Extending Multi-Tenant Behavior To Northwind

As now we have a behavior handling repository details, we just need to add IMultiTenantRow interface to rows and add TenantId property.

Start with SupplierRow.cs:

  1. namespace MultiTenancy.Northwind.Entities
  2. {
  3. //...
  4. public sealed class SupplierRow : Row,
  5. IIdRow, INameRow, IMultiTenantRow
  6. {
  7. //...
  8. [Insertable(false), Updatable(false)]
  9. public Int32? TenantId
  10. {
  11. get { return Fields.TenantId[this]; }
  12. set { Fields.TenantId[this] = value; }
  13. }
  14. public Int32Field TenantIdField
  15. {
  16. get { return Fields.TenantId; }
  17. }
  18. //...
  19. public class RowFields : RowFieldsBase
  20. {
  21. //...
  22. public readonly Int32Field TenantId;
  23. }
  24. }
  25. }

When you these changes in SupplierRow and build, you’ll see that tenant2 can’t see suppliers from other tenants in suppliers page.

Now repeat these for EmployeeRow, CategoryRow, CustomerRow, ShipperRow, OrderRow, ProductRow, RegionRow and TerritoryRow.