MultiTenancyの処理方法に関するご意見をお聞きしたいと思います。 I "私のバックエンドとしてMVC3(MVC4への切り替え)とEFを使用して、私は、単一のアプリケーション、共有スキーママルチテナントを使用しています以下は、mはコードです:。。もちろんDIのMVCでのMulti Tenancyの処理
public abstract class Service<T> where T : Entity
{
private Repository<T> _repo;
public Service()
{
_repo = new Repository<T>();
}
public bool Authenticate(int id)
{
//var companyInfo = _authorizationRepository.GetApiKey(apiKey);
int tenantId = 0; // replaced by companyInfo using repository
var entity = _repo.GetQuery(tenantId).Where(e => e.Id == id).First();
if (tenantId != entity.TenantId)
throw new ArgumentException();
return true;
}
}
public class EmployeeService : Service<Employee>
{
private EmployeeRepository employeeRepository;
public EmployeeService()
{
employeeRepository = new EmployeeRepository();
}
public Employee GetEmployeeById(int employeeId)
{
this.Authenticate(employeeId);
return employeeRepository.GetById(employeeId);
}
}
public class Entity
{
public int Id { get; set; }
public int TenantId { get; set; }
}
が同様に存在しますが、用シンプルさ私はここでそれらを削除しました(一時的に)。私はジェネリックス(それについて汚れている)をサービスレイヤーで使用しました。テナントIDとクラスに渡される正しいエンティティとの比較に問題があります。これはFilterAttributesを使用していますが、どのようにすればいいのかわかりません。あなたのマルチテナント性はどうやって処理しますか?設計には長期的に遭遇する可能性のある重大な欠陥がありますか?
Th anks!
なぜWebアプリケーションでマルチテナントが問題になるのですか? – Tejs
@Tejs私の懸念は、ルーティングをどのように処理するかということです。基本的にtenant1.domain.comとdomain.com/tenant2の両方が有効で、特定のテナントを指している必要があります。 – MikeSW
それは素晴らしいですが、その特定のURLスキームは、使用することを決めた永続性レイヤーとは関係ありません。私はあなたの質問が何であるか疑問に思います。 – Tejs