Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A common way to do this is to have your enumeration specified in a common low level assembly that can be referenced by any other assembly (every project i've ever worked on has some sort of Framework or Common assembly).</p> <p>In your definition of the enum, you can specify actual values:</p> <pre><code>public enum Status { None = 0, Draft = 1, Ready = 2 ... etc ... } </code></pre> <p>Do not be concerned about the need for recompilation if a status value is added. If that status value is actually going to be used then you will have to add new code anyway (why do you care about a new status value if your code is never going to make decisions based on it?). So somewhere in your code you will have something like this:</p> <pre><code>if (myObject.Status == Status.MyNewValue) ... carry out some action ... </code></pre> <p>and the assembly containing this code will need to be recompiled, as will the common assembly where the enum is defined (so that the new value can be seen from the assembly this code is in). The database people can create as many Status values as they want, if you don't specifically use them then you don't need to recompile. Of course there are exceptions to this rule - because an Enum is by default an <code>int</code> you can read in any status value from the database and assign it to your Status property, but it will fail serialization if you have not explicitly defined that status enum value in your enum definition.</p> <p>So to make a long story short: don't worry about the recompilation aspect, just do it - your status values won't change that often :)</p> <p>Also, if you are worried about the <em>name</em> of the enum value, then that can be addressed by mapping enum values to strings in a resource file, that string is what you show in your data grid or anywhere else the enum is surfaced through the UI. If you business specialists are changing the definition of the enum though (like '1' now means 'Ready' and '2' now means 'Draft') then that is just plain silly and they shouldn't be doing that - if they are then you will have to refactor your code anyway.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload