Dynamic creation of models - entities using Asp.Net MVC
So, i have my database sorted like:
Products_001 Products_002 Products_003
Let's say, if a customer logs in and his id is 001, he is only entitled to use the database-table products_001.
Can i dynamically create his 开发者_C百科model - entity using Asp.Net MVC, and how would i do this?
ProductsBase products = Activator.CreateInstance(
"YourAssembly.Namespace",
"Products_" + Login.Id);
http://msdn.microsoft.com/en-us/library/d133hta4.aspx
You may need to have a base type/interface for your different product types
NicoJuicy,
The way we handled this was to have a generic model (Using EF) and different DB's for each table. When the user logs in we bind the Model to the appropriate Db using the connection string and the user info.
If this sounds like what you want let me know and I will post more details.
Andrew
精彩评论