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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:40:07+00:00 2026-05-31T10:40:07+00:00

Hi I wonder if anyone can solve my problem. I tried looking for a

  • 0

Hi I wonder if anyone can solve my problem. I tried looking for a solution but no idea where to even start looking.

I am trying to create my own user system where user details are kept in a database.

I have a user class, this contains user information, for example, id, first name, last name and user type. User type is a normal user, moderator, admin.

my problem is the UserType. Sometimes its a string and sometimes its an int and I am not sure how to create a class to handle this without dupplicating the class but one with UserType as int and another as string.

For example
1 = admin
2 = moderator

Also the user class brings back different information, for example I only want to contain first name and surname and sometimes I want to contain username and active and not active.

Again I do not want to create a seperate class for each but I don’t want to bring back the data I do not need.

What would be the best approach?

  • 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-31T10:40:09+00:00Added an answer on May 31, 2026 at 10:40 am

    You have several questions here which should probably be split up…

    my problem is the UserType. Sometimes its a string and sometimes its
    an int

    Don’t do that then. Its a slightly trite answer but your user type is either a string or it is an int. Work out which one it really is or you want it to be and make it that.

    You can use enums though of course these are hardcoded so you can’t easily add or remove but they do at least have the benefit of allowing you to bridge the string to int divide.

    Probably better if you need to use both would be to have a lookup in your database (ie a table that matches strings to ints) and you can then have a method somewhere that looks it up (possibly only getting the conversions from the database once and then caching them rather than do a DB call for each lookup).

    Also the user class brings back different information, for example I
    only want to contain first name and surname and sometimes I want to
    contain username and active and not active.

    Again I do not want to create a seperate class for each but I don’t
    want to bring back the data I do not need.

    How much data is there? In most cases you wouldn’t be looking at much overhead if you bought back all the data each time and it would be easier because you would always know that a user object contained all the info it needed. If you are particularly worried about getting large amounts of data you don’t need you could look at Lazy Loading which may do what you want. You will probably find though that adding an “active” flag into a data request to the DB is a lot less overhead than making a second DB call would be if you do decide you want that info.

    In essence this is very likely to ever be a performance bottleneck unless the user has some massive bits of data associated with it. A username, first name and second name and things that are generally measured in bytes like that are unlikely to cause problems for you so I wouldn’t worry about it until you can prove they are a performance bottleneck. At that point you can worry about Lazy Loading or similar to sort out your problems.

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

Sidebar

Related Questions

I wonder is anyone can help me with this annoying problem. Trying to insert
I wonder if anyone can help with a jQuery problem I am having. I
Wonder if anyone can help me, the map displays fine but the marker does.
Wonder if anyone can help, I'm looking for a way to take an image
wonder if anyone can help - I thought I had solved this but i
Wonder if anyone can help me with this problem. I have created a Window
I'm trying to solve the group-wise max problem in LINQ. To start, I have
I wonder if anyone can point me in the right direction I'm fairly new
I wonder if anyone can help improve my understanding of JOINs in SQL. [If
I wonder if anyone can think of a good technique to enable any arbitrary

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.