Another way to approach this is through front-end validation / filtering. I encountered a scenario where, on the db level, I needed to allow the db to save a field to any of the enum values, but I didn't want the end user to see invalid options. So, I created an attribute for the enum values specifying what kind of user could see those enum values.
public class FieldAttribute : Attribute
{
public int FilterProperty { get; set; }
}
Then I decorated the enum values with that attribute.
public enum myEnum{
ZeroValue,
[Field(FilterProperty = 0)]
FirstValue,
[Field(FilterProperty = 1)]
SecondValue,
[Field(FilterProperty = 0)]
ThirdValue,
[Field(FilterProperty = 1)]
FourthValue,
}
then i created an extension method that provided a dictionary of only the values that type of user could see.
public static IDictionary<int, string> PrepareAcceptableValues(int filterVal) {
var values = Enum.GetValues(typeof(myEnum));
var retval = new List<myEnum>();
foreach (var value in values) {
try { //if enum value has an attribute type...
var assignedFilterProp = value.GetType().GetMember(value.ToString()).First().GetCustomAttribute<FieldAttribute>().FilterProperty;
if (assignedFilterProp.Equals(filterVal)) //if enum value has the correct filter property
retval.Add((myEnum)value); //add it in
}
catch (Exception e) {
retval.Add((myEnum)value); //if enum value has no attribute, add it in
}
}
return retval.ToDictionary(i => (int)i, i => i.toString());
Then, when the data came in on the front end, as long as whatever they pick is part of the base enum, the DB can save it.
Not really answering your question directly, but an indirect route that might help you get what you're after.