Usually we generate transfers from the database. We use CodeSmith , which allows us to create project files that can easily regenerate enumerations as needed.
We sometimes met, as a rule, for reporting purposes (when existing enumeration values are preserved).
And, of course, we have enumerations whose values are never stored.
In general, the only reason for generating transfers from the database is that the code must make decisions based on them. If you just want to populate the ComboBox and save the user's choice, do not create an enumeration.
Obviously, making decisions based on enumerations (or strings) whose values can change is fragile. You might want to consider including the expiration dates (or “from” and “to”) in your database schema so that existing values are not deleted. Filter outdated values when populating user interface selectors. It also facilitates referential integrity.
As always in C #, you should be aware that enumeration values may fall outside the expected range. Turn default on switch .
We have developed helper classes for creating cached query lists that simplify their use.
I do not protect this route. If necessary, we did it.
source share