Reputation: 26004
Is there a way that I can use to create Enums dynamically? I'm trying to get the names of tables inside a database and create a list of Enums which I would use when coding inside Visual Studio. Is it even possible?
I think I can get the name of tables in a database but the later part, I have no idea about it.
Upvotes: 0
Views: 1577
Reputation: 191058
You can't create an enum easily at runtime.
However, you can use a T4 template to query your database and create a code file that could be compiled in.
Upvotes: 3
Reputation: 245
There isnt a way of doing this, you could manually create an enum that represents the database,
Maybe it would be better if you used a Dictionary<int, string>
Upvotes: 1