最佳实践来转换一个NHibernate的应用程序的多租户? [英] Best practices to convert a NHibernate app as multi-tenant?
问题描述
我有一个简单的ASP.NET MVC +的OpenID + NHibernate的应用(上MSSQL Server数据库的顶部)。该应用程序是严格的单租户和支持多用户只有2个角色(管理的和的用户的)。
I have a simple ASP.NET MVC + OpenID + NHibernate app (on top of MSSQL Server DB). The app is strictly single tenant and supports multiple users with only 2 roles (Admin and User).
我想这个应用程序转换为多租户应用程序。我的要求是有限的:我只需要介绍的概念的帐户的S,每个帐户有它自己的用户群和行为酷似原非多租户应用程序。有账户之间没有相互作用。
I would like to convert this app into a multi-tenant app. My requirements are limited: I just need to introduce the notion of Accounts, each account having its own set of users and behaving exactly like the original non-multi-tenant app. There is no interactions between accounts.
什么是做这个迁移最简单的方式的最佳实践?特别是,我可以手动更新所有实体和存储库有* ACCOUNT_ID *领域,并上传逻辑了。但是,我想知道,如果没有更聪明的方法是会以某种抽象的这个方面。
What are the best practices to do this migration the most simple way? In particular, I am can manually update all entities and repositories with an *Account_id* field, and upload the logic too. But, I am wondering if there are no smarter approaches that would somehow abstract this aspect.
诗:应用程序是很轻,我的不的希望引进一个新的数据库实例每个帐户
Ps: the app is very light, I do not wish to introduce a new DB instance for each account.
推荐答案
也许我能想到的最好的事情就是拥抱的NHibernate的过滤功能。它可以让你轻松地启用您正在运行的查询过滤器,你可以选择让他们的那些设置是多租户表
Probably the best thing I could think of is to embrace the Filter feature of NHibernate. It allows you to easily enable a filter on the query you're running and you can optionally enable them on tables that are setup to be multi-tenanted
这篇关于最佳实践来转换一个NHibernate的应用程序的多租户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!