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

  • Home
  • SEARCH
  • 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 7726905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:19:38+00:00 2026-06-01T05:19:38+00:00

Imagine a class like this: public class MyEntity : Entity { public virtual States

  • 0

Imagine a class like this:

public class MyEntity : Entity
{
    public virtual States States { get; set; }
}

[Flags]
public enum States
{
    None,
    State1 = 1,
    State2 = 2,
    State3 = 4,
    State4 = 8
}

I want to map it to this table:

TABLE MY_ENTITY
ID: PK
STATES_ID : FK to MY_ENTITY_STATES

TABLE MY_ENTITY_STATES
ID: PK
IS_STATE1_SET (bit)
IS_STATE2_SET (bit)
IS_STATE3_SET (bit)
IS_STATE4_SET (bit)

Is this possible?

This is a legacy scenario, I can’t change the database.


As per request, here is some sample data:

Table MY_ENTITY

ID | STATES_ID
---+----------
14 | 35

Table MY_ENTITY_STATES

ID | IS_STATE1_SET | IS_STATE2_SET | IS_STATE3_SET | IS_STATE4_SET
---+---------------+---------------+---------------+--------------
35 | 0             | 1             | 0             | 1

This should lead to a value of States.State2 | States.State4 in the States property in the MyEntity instance with the ID 14.

  • 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-06-01T05:19:40+00:00Added an answer on June 1, 2026 at 5:19 am

    This is a two step solution.

    First, use join to bring the MY_ENTITY_STATES record, and then write a IUserType that converts the flags to columns.

    Check here for an example.

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

Sidebar

Related Questions

imagine this: public class Foo { private IList<string> WasSet; public string Prop1 {get;set;} public
I imagine to use XML serialization like this: class Foo { public Foo (string
Let's imagine something like this: class MyTable extends Doctrine_Table { public function construct() {
Imagine that I have a generic base class like this: public abstract class AnimalDTO<TA,
Imagine we have a class like this: class Testee { public: void Func() private:
Imagine a simple case like this: class Book has_many :chapters end Let's say in
Imagine a base class with many constructors and a virtual method public class Foo
Like this: public class remoteStatusCounts : RemoteStatus { public int statusCount; public remoteStatusCounts(RemoteStatus r)
I have a Generic class like this : public class Mapper<TEntity, TDataAccess> where TEntity
Say I have a class like this: public class FauxIdentityForm { public Guid FormID

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.