-3
With asp.net-core service injection
如何添加multi-tenant unitofwork
(包含多個存儲庫)?c#netcore 1.1 unitofwork multitenant
在我的代碼現在,我有一個SetTenantId
功能,在每個存儲庫更新tenantId
:
public class ContinentsController : Controller, ICustomApiController<Continent>
{
private readonly IUnitOfWork _data;
public ContinentsController(IUnitOfWork unitOfWork)
{
_data = unitOfWork;
_data.SetTenantId(currentUserTenantId);
}
}
public interface IUnitOfWork : IDisposable
{
ITicketRepository Tickets { get; }
int Save();
void SetTenantId(int tenantId);
}
有沒有其他的解決辦法?
只要使用谷歌...所有你需要的是閱讀的測試: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection –