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 148591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:59:10+00:00 2026-05-11T08:59:10+00:00

I have a data object (let’s say it’s called ‘Entry’) that has a set

  • 0

I have a data object (let’s say it’s called ‘Entry’) that has a set of potential states that look something like this:

1 - Created 2 - File added 3 - Approved 4 - Invalid

This is represented in the database with a ‘Status’ table with an autonumber primary key, then a ‘StatusId’ field in the main table, with the appropriate relationships set up.

In my (custom) data layer, I have the ‘Entry’ object, and, currently, I also declare an Enum with the states listed above specified. Finally I declare a private instance of this Enum along with the appropriate public property.

In my ‘Commit()’ method I cast the instance of the Enum to an integer and pass it to an Update stored procedure.

In my static ‘GetEntry()’ method I will obviously have an integer passed back from the database. I then use the ‘Enum.Parse()’ method to extract an object which is an instance of my Enum which corresponds to the returned status integer. I cast this to the type of my Enum and assign it to the local private variable.

My question is pretty simple – is this approach appropriate, and if not what alternative, other than just storing the raw integer value (which i’m not necessarily averse to), is better.

My reason for asking is that this all just seems incredibly messy to me, what with all the casting and maintaining two lists of the same set of values. I accept the benefit lies in a better experience for the consumer of the data object, but even so…

Thanks!

  • 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. 2026-05-11T08:59:10+00:00Added an answer on May 11, 2026 at 8:59 am

    We have something familiar in one of our projects. We have a table containting types of items. These types have an id, in the code we have an enum with the same id’s. The thing is, in the database we don’t use autonumber (identity) so we have full control of the id. And when saving our object we just take the id of the enum to save the object. I also thought this approach was messy but it’s not that bad afterall.

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Don't do this: <input type="checkbox" name="del_#ItemHasUsers[i]["ID"]#"> Do this: <input type="checkbox"… May 11, 2026 at 11:52 pm
  • Editorial Team
    Editorial Team added an answer Have you looked at Lucene? It's open-source and the Java… May 11, 2026 at 11:52 pm
  • Editorial Team
    Editorial Team added an answer One "normal" way would be to create a new Bitmap… May 11, 2026 at 11:52 pm

Related Questions

I have a data object (let's say it's called 'Entry') that has a set
I have a WPF ListBox bound to a data object. Inside the listbox are
I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,
I am writing this in C# using .NET 3.5. I have a System.Data.DataSet object
Let's say I'm building a data access layer for an application. Typically I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.