Using database config data in code

[.NET 3.5]
In have several configuration tables in a db and map them via an enum in my .NET app.  The enum may look like this:

public enum TransactionTypes{
start = 1,
end = 2,
complete = 3}

where each number corresponds to an ID column in a corresponding table.   This approach is error prone and not very scalable.  A change in the ID column value can disassociate the enum mapping.  You also have to remember to add any new IDs.   The enum is nice though since I can get great intellisense in code:

public static void SomeMethod(TransactionTypes trans){...}

MyClass.SomeMethod(TransactionTypes.{all enums display})

Is there a way to accomplish this without the problems mentioned above?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Do you want (or need) Intellisense mapping?  The approach that I usually take is to have a TransactionType lookup table that you can access with an SQL inner join.

SQL Server example:

TransactionTypeID, int
TransactionTypeName, varchar(25)
brettrAuthor Commented:
Yes - I'd like to have intellisense.
Bob LearnedCommented:
Do you know anything about code generation, like CodeSmith?  There aren't a lot of options when you require Intellisense, and you want to avoid errors and sins of omission.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Well,you can use the enum even if the integer values do not exist in your enum class.
It only becomes an issue if you use them by name.
E.g if you require to use TransactionTypes.start anywhere in your code, it must exist.

But if you need to use an undefined value, e.g. TransactionTypes.failed you will notice it during development that your value is missing.
Code generation tools might help, like TheLearnedOne said, I personally liked MyGeneration since it's free.
Maybe you need to wonder why ppl add lookup values to the database if the business logic does not use/expose them.
brettrAuthor Commented:
Can you comment on how you use MyGeneration specifically?  I'm just starting to read up on it.
It's merely based on database driven code generation. It has templates included when you download it, but it's easy to write your own using VB script. The help is self explaining, or based on the included templates it's easy to create your own
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.