Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3612664
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:01:45+00:00 2026-05-18T22:01:45+00:00

I have a database table that essentially contains different types of things. I’ll use

  • 0

I have a database table that essentially contains different types of things. I’ll use animals as an example. I have a table called AnimalTypes:

AnimalTypes
{
     ID:int,
     Name:string
}

I then populate it with:

1:Dog,
2:Cat,
3:Fish

I would like to then have some sort of C# object created that functions similar to this enum be entirely read from the database:

enum AnimalTypes
{
     Dog = 1,
     Cat = 2,
     Fish = 3
}

Is there a way to create an enum/class from a database table as described? I basically want to be able to reference things in the AnimalTypes table using intellisense and AnimalTypes.Dog as an example; I don’t actually need an enum, just something that kind of functions like one. Is this possible?

Edit: I’m not really that thrilled about generating a DLL as I’ve seen in other related problems. I feel like this should be possible with reflection.

Lets suppose I don’t need intellisense.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:01:45+00:00Added an answer on May 18, 2026 at 10:01 pm

    You will have to generate an assembly if you want to be able to use the enumeration or class at compilation time. Reflection happens at execution time so that won’t give you intellisense.

    This is a common problem – there are a set of distinct values in a database table and those values don’t change often so they are modeled as an enum in the source code. This allows these somewhat static values to be easily used in a very readable way. The problem is that when the values do change, it would be nice if the enum changed as well.

    The problem with trying to keep the enum and database in sync is that an automatic process doesn’t change the fact that if you are changing the database it would be very unlikely that you would do so without having to roll new code to leverage the changed value. It is better to model these values as an enum and still store them in the database. Just manually sync them as the need arises.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database schema that contains multiple tables with different names, but all
I have a database table (called Info) that stores [Data], [fkID], [UserID], [Timestamp]. [Data]
I have a database that essentially looks like this: id uniqueidentifier NOT NULL data
I have a SQL Server 2005 database that stores data for multiple users. Each
I have a database with the following tables: create table Categories ( Id int
I am working with a poorly designed database that I am not at liberty
I'm creating an virtual stamp card program for the iphone and have run into
Maybe this is a shot in the dark here but I'm trying to find
I am building a browser game with a mini map of the surroundings of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.