NicoJuicy
NicoJuicy

Reputation: 3528

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 model - entity using Asp.Net MVC, and how would i do this?

Upvotes: 0

Views: 327

Answers (2)

abarr
abarr

Reputation: 1140

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

Upvotes: 0

Anthony Johnston
Anthony Johnston

Reputation: 9584

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

Upvotes: 4

Related Questions