Reputation: 384
I am creating a database system where there are tables that have some data that are not user derived, they will be used by the app for lookup mainly. But for the database performance and query optimization I decided to use enums for these lookups and store their ints in the table instead of the entire word.
I want to make an enum called diseases and they are 500 types.
So, can I create an enum in C# (.net core) that has 500 members and, if not, how can I achieve such thing? Also, is there a way to localize the values in enums?
I use the enums because they will save me the joining when I make queries in database. If I didn't use enums I would have to query a table then make 2 joins with another 2 tables that have the lookup data. If I make them with enums though, I only need the number which will be saved in the first table and in the app get its string and I will save the query from using 2 joins every time I get the data.
Upvotes: 2
Views: 234
Reputation: 4733
Can I create an enum in C# (.net) that has 500 members
Sure, if you want to.
But I think it's a bad idea. Imagine if someone else wants to use your Database, they'll then have to have a copy of the same enum
, which means you'll have to maintain 2 (or more) copies of the same list as long as other people need it and I don't think anyone wants to do that.
500 rows in a Database is like nothing, making it into an enum
won't help you that much (at least not something you can notice), instead just store them in a Table and everyone is happy.
Is there a way to localize the values in enums
No, not out-of-the-box. You will have to create your own solution for this. It depends on where and how your localizations are stored.
Upvotes: 6